Skip to content

Commit

Permalink
hardcode url
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed May 15, 2024
1 parent 72f292c commit 20c6d9a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
18 changes: 10 additions & 8 deletions examples/starknet-react-next/src/components/StarknetProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ export function StarknetProvider({ children }: PropsWithChildren) {
);
}

const url =
process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL === "preview"
? "https://" +
(process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL as string).replace(
"cartridge-starknet-react-next",
"keychain",
)
: process.env.XFRAME_URL;
// const url =
// process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL === "preview"
// ? "https://" +
// (process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL as string).replace(
// "cartridge-starknet-react-next",
// "keychain",
// )
// : process.env.XFRAME_URL;

const url = "https://keychain-git-deployment-required.preview.cartridge.gg";
const connectors = [
new CartridgeConnector(
[
Expand Down
9 changes: 5 additions & 4 deletions packages/keychain/src/utils/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ class Account extends BaseAccount {
//transactionsDetail.maxFee = num.toHex(transactionsDetail.maxFee);
transactionsDetail.maxFee = "0x38D7EA4C68000"; // 0.001 eth

const res = await this.cartridge.execute(
calls as Array<Call>,
transactionsDetail,
);
const res = await this.cartridge
.execute(calls as Array<Call>, transactionsDetail)
.catch((e) => {
throw new Error("Execute error: " + e.message);
});

Storage.update(this.selector, {
nonce: (BigInt(transactionsDetail.nonce) + 1n).toString(),
Expand Down
24 changes: 8 additions & 16 deletions packages/keychain/src/utils/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ export default class Controller {
protected credentialId: string;
protected accounts: Account[];

constructor(
address: string,
publicKey: string,
credentialId: string,
options?: {
rpId?: string;
origin?: string;
},
) {
constructor(address: string, publicKey: string, credentialId: string) {
this.address = address;
this.publicKey = publicKey;
this.credentialId = credentialId;
Expand Down Expand Up @@ -63,18 +55,18 @@ export default class Controller {
process.env.NEXT_PUBLIC_RPC_SEPOLIA,
constants.StarknetChainId.SN_SEPOLIA,
address,
options?.rpId || process.env.NEXT_PUBLIC_RP_ID,
options?.origin || process.env.NEXT_PUBLIC_ORIGIN,
process.env.NEXT_PUBLIC_RP_ID,
process.env.NEXT_PUBLIC_ORIGIN,
credentialId,
publicKey,
this.session(
"http://localhost:3002",
constants.StarknetChainId.SN_SEPOLIA,
),
undefined,
),
),
];

console.log({ origin: process.env.NEXT_PUBLIC_ORIGIN });
console.log({ rp_id: process.env.NEXT_PUBLIC_RP_ID });

Storage.set(
selectors[VERSION].admin(this.address, process.env.NEXT_PUBLIC_ADMIN_URL),
{},
Expand Down Expand Up @@ -124,7 +116,7 @@ export default class Controller {
const credentials = await account.cartridge
.createSession(policies, expiresAt)
.catch((e) => {
console.log(e);
throw new Error(e.message);
});

Storage.set(selectors[VERSION].session(this.address, origin, chainId), {
Expand Down

0 comments on commit 20c6d9a

Please sign in to comment.