Skip to content

Commit

Permalink
Merge pull request #104 from argentlabs/fix/snjs-argent-mobile
Browse files Browse the repository at this point in the history
fix: update argent mobile rpc methods
  • Loading branch information
bluecco authored Jul 3, 2024
2 parents a03939d + 5ad6ec4 commit 07dd240
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/connectors/argentMobile/modal/starknet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class StarknetRemoteAccount extends Account implements AccountInterface {
? transactionsDetail
: abisOrDetails

return await this.wallet.starknet_requestAddInvokeTransaction({
return await this.wallet.wallet_requestAddInvokeTransaction({
accountAddress: this.address,
executionRequest: { calls, invocationDetails: details },
})
Expand Down
20 changes: 19 additions & 1 deletion src/connectors/argentMobile/modal/starknet/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class StarknetAdapter
"starknet_supportedSpecs",
"starknet_signTypedData",
"starknet_requestAddInvokeTransaction",
"wallet_supportedSpecs",
"wallet_signTypedData",
"wallet_requestAddInvokeTransaction",
]
public events = ["chainChanged", "accountsChanged"]

Expand Down Expand Up @@ -103,6 +106,9 @@ export class StarknetAdapter
starknet_addInvokeTransaction: this.handleAddInvokeTransaction,
starknet_signTypedData: this.handleSignTypedData,
starknet_supportedSpecs: this.handleSupportedSpecs,
wallet_addInvokeTransaction: this.handleAddInvokeTransaction,
wallet_signTypedData: this.handleSignTypedData,
wallet_supportedSpecs: this.handleSupportedSpecs,
})
}

Expand All @@ -123,7 +129,19 @@ export class StarknetAdapter
throw new Error("No session")
}

const requestToCall = this.handleRequest[call.type]
let type = call.type as string

// temporarily for backwards compatibility
if (
type === "wallet_addInvokeTransaction" ||
type === "wallet_supportedSpecs" ||
type === "wallet_signTypedData"
) {
type = type.replace("wallet_", "starknet_") as string
}

const requestToCall = this.handleRequest[type]

if (requestToCall) {
return requestToCall(call.params)
}
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/argentMobile/modal/starknet/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class StarknetRemoteSigner implements SignerInterface {
typedData: TypedData,
accountAddress: string,
): Promise<Signature> {
const { signature } = await this.wallet.starknet_signTypedData({
const { signature } = await this.wallet.wallet_signTypedData({
accountAddress,
typedData,
})
Expand Down
4 changes: 2 additions & 2 deletions src/connectors/argentMobile/modal/starknet/starknet.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { TypedData } from "starknet-types"

// see https://github.com/WalletConnect/walletconnect-docs/pull/288/files
export interface IStarknetRpc {
starknet_signTypedData(params: {
wallet_signTypedData(params: {
accountAddress: string
typedData: TypedData
}): Promise<{ signature: Signature }>
starknet_requestAddInvokeTransaction(params: {
wallet_requestAddInvokeTransaction(params: {
accountAddress: string
executionRequest: {
calls: Call[]
Expand Down

0 comments on commit 07dd240

Please sign in to comment.