-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Darlington02/develop
feat: Implement TBAStarknetWindowObject
- Loading branch information
Showing
10 changed files
with
173 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 35 additions & 3 deletions
38
connector/src/connector/windowObject/TBAStarknetWindowObject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,36 @@ | ||
// modified and updated version of the starknetWindowObject, important links below: | ||
import type { | ||
ConnectedStarknetWindowObject, | ||
StarknetWindowObject | ||
} from "get-starknet-core"; | ||
|
||
// https://github.com/argentlabs/starknetkit/blob/develop/src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts | ||
// https://github.com/starknet-io/get-starknet/blob/master/packages/core/src/StarknetWindowObject.ts#L75 | ||
import type { | ||
AccountInterface, | ||
ProviderInterface | ||
} from "starknet"; | ||
|
||
import { TokenboundAccount } from "./tokenboundAccount"; | ||
|
||
export async function updateStarknetWindowObject( | ||
wallet: StarknetWindowObject, | ||
provider: ProviderInterface, | ||
tokenboundAddress: string, | ||
parentAccount: AccountInterface | ||
): Promise<ConnectedStarknetWindowObject> { | ||
const chainId = await provider.getChainId() | ||
|
||
const valuesToAssign: Pick< | ||
ConnectedStarknetWindowObject, "id" | "name" | "icon" | "version" | "isConnected" | "chainId" | "selectedAddress" | "account" | "provider" | ||
> = { | ||
id: "TBA", | ||
name: "Tokenbound Account", | ||
icon: "https://tokenbound.org/_next/image?url=%2Ftb-mark.svg&w=96&q=75", | ||
version: "1.0.0", | ||
isConnected: true, | ||
chainId, | ||
selectedAddress: tokenboundAddress, | ||
account: new TokenboundAccount(provider, tokenboundAddress, parentAccount), | ||
provider | ||
} | ||
|
||
return Object.assign(wallet, valuesToAssign) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
Signature, | ||
Account, | ||
AccountInterface, | ||
ProviderInterface, | ||
SignerInterface, | ||
Call, | ||
CallData, | ||
} from "starknet"; | ||
|
||
class UnimplementedSigner implements SignerInterface { | ||
async getPubKey(): Promise<string> { | ||
throw new Error("Method not implemented"); | ||
} | ||
|
||
async signMessage(): Promise<Signature> { | ||
throw new Error("Method not implemented"); | ||
} | ||
|
||
async signTransaction(): Promise<Signature> { | ||
throw new Error("Method not implemented"); | ||
} | ||
|
||
async signDeclareTransaction(): Promise<Signature> { | ||
throw new Error("Method not implemented"); | ||
} | ||
|
||
async signDeployAccountTransaction(): Promise<Signature> { | ||
throw new Error("Method not implemented"); | ||
} | ||
} | ||
|
||
export class TokenboundAccount extends Account implements AccountInterface { | ||
public signer = new UnimplementedSigner(); | ||
|
||
constructor( | ||
provider: ProviderInterface, | ||
public address: string, | ||
public parentAccount: AccountInterface | ||
) { | ||
super(provider, address, new UnimplementedSigner); | ||
} | ||
|
||
override execute = async ( | ||
calls: Call[] | ||
) => { | ||
try { | ||
let call: Call = { | ||
contractAddress: this.address, | ||
entrypoint: '__execute__', | ||
calldata: CallData.compile({ | ||
calls | ||
}) | ||
} | ||
return await this.parentAccount.execute(call); | ||
} | ||
catch(error) { | ||
console.log(error); | ||
throw new Error("Error while executing a transaction"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
// modal UI goes here | ||
import React from "react"; | ||
|
||
function index() { | ||
return ( | ||
<div>Modal goes in here</div> | ||
) | ||
} | ||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
export type { TokenboundClientOptions, GetAccountOptions, CreateAccountOptions, AccountStatus, Call, LockOptions, LockStatus, GetOwnerOptions, ERC20TransferOptions, NFTTransferOptions } from "./TokenboundClient" | ||
export type { | ||
TokenboundClientOptions, | ||
GetAccountOptions, | ||
CreateAccountOptions, | ||
AccountStatus, | ||
Call, | ||
LockOptions, | ||
LockStatus, | ||
GetOwnerOptions, | ||
ERC20TransferOptions, | ||
NFTTransferOptions | ||
} from "./TokenboundClient" | ||
|
||
export type { WalletClient } from "./walletClient" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters