@xrpl-wallet-kit/adapter-gemwallet 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,9 +53,9 @@ When using `@xrpl-wallet-kit/client` defaults, GemWallet is already included.
|
|
|
53
53
|
|
|
54
54
|
## Auto Reconnect
|
|
55
55
|
|
|
56
|
-
GemWallet restore is intentionally conservative. The stored dApp session is not treated as proof that the extension is still connected. On reload, the adapter must read the active GemWallet address and compare it with the stored
|
|
56
|
+
GemWallet restore is intentionally conservative. The stored dApp session is not treated as proof that the extension is still connected. On reload, the adapter must read the active GemWallet address and compare it with the stored account address.
|
|
57
57
|
|
|
58
|
-
`restoreSession()`
|
|
58
|
+
`restoreSession(session, options?)` reads the current address and, for chain-aware adapters, the current network. Xahau restore also requires the manager's registered protocol context; cached keys and RPC URLs are not trusted. Missing or rejected network information requires explicit reconnect, even where explicit connect permits a configured-preset fallback. Restore never calls connect, signing or submission. Normal stale or unavailable states return `null`.
|
|
59
59
|
|
|
60
60
|
## Testing
|
|
61
61
|
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface GemWalletProvider {
|
|
|
21
21
|
isInstalled?: () => Promise<GemWalletBooleanResponse>;
|
|
22
22
|
isConnected?: () => Promise<GemWalletBooleanResponse>;
|
|
23
23
|
getAddress?: () => Promise<{
|
|
24
|
+
type?: string;
|
|
24
25
|
result?: {
|
|
25
26
|
address?: string;
|
|
26
27
|
};
|
|
@@ -81,6 +82,7 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
81
82
|
} | undefined;
|
|
82
83
|
raw: {
|
|
83
84
|
address: {
|
|
85
|
+
type?: string;
|
|
84
86
|
result?: {
|
|
85
87
|
address?: string;
|
|
86
88
|
};
|
|
@@ -89,20 +91,21 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
89
91
|
network: GemWalletNetworkResponse | undefined;
|
|
90
92
|
};
|
|
91
93
|
}>;
|
|
92
|
-
restoreSession(session: WalletSession): Promise<{
|
|
94
|
+
restoreSession(session: WalletSession, options?: ConnectOptions): Promise<{
|
|
93
95
|
account: {
|
|
94
|
-
address: string;
|
|
95
96
|
publicKey?: string;
|
|
96
|
-
network?: import("@xrpl-wallet-kit/core").WalletNetwork;
|
|
97
97
|
networkType?: string;
|
|
98
|
+
address: string;
|
|
99
|
+
network: import("@xrpl-wallet-kit/core").WalletNetwork | undefined;
|
|
98
100
|
activationStatus?: "active" | "unfunded" | "unknown";
|
|
99
101
|
};
|
|
100
102
|
session: {
|
|
103
|
+
metadata?: Record<string, unknown>;
|
|
101
104
|
account: {
|
|
102
|
-
address: string;
|
|
103
105
|
publicKey?: string;
|
|
104
|
-
network?: import("@xrpl-wallet-kit/core").WalletNetwork;
|
|
105
106
|
networkType?: string;
|
|
107
|
+
address: string;
|
|
108
|
+
network: import("@xrpl-wallet-kit/core").WalletNetwork | undefined;
|
|
106
109
|
activationStatus?: "active" | "unfunded" | "unknown";
|
|
107
110
|
};
|
|
108
111
|
adapterId: string;
|
|
@@ -110,9 +113,11 @@ export declare class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
110
113
|
connectedAt: number;
|
|
111
114
|
expiresAt?: number;
|
|
112
115
|
balance?: import("@xrpl-wallet-kit/core").WalletSessionBalance;
|
|
113
|
-
metadata?: Record<string, unknown>;
|
|
114
116
|
};
|
|
115
|
-
raw:
|
|
117
|
+
raw: {
|
|
118
|
+
address: unknown;
|
|
119
|
+
network: GemWalletNetworkResponse | undefined;
|
|
120
|
+
};
|
|
116
121
|
} | null>;
|
|
117
122
|
signMessage(request: SignMessageRequest): Promise<{
|
|
118
123
|
signatureKind: "signature";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAkO,MAAM,uBAAuB,CAAC;AAC1R,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAyB,MAAM,uBAAuB,CAAC;AAE1O,eAAO,MAAM,cAAc,24JAA24J,CAAC;AAEv6J,KAAK,wBAAwB,GAAG,OAAO,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,GAAG;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,CAAC;AAClH,KAAK,wBAAwB,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEzI,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtD,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAkO,MAAM,uBAAuB,CAAC;AAC1R,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,sBAAsB,EAA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publicKey?.raw, network }
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
async restoreSession(session) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
await this.assertProviderState(provider);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
this.account = undefined;
|
|
74
|
+
async restoreSession(session, options = {}) {
|
|
75
|
+
const generation = ++this.generation;
|
|
76
|
+
this.account = undefined;
|
|
77
|
+
this.protocolContext = undefined;
|
|
78
|
+
const assertCurrent = () => {
|
|
79
|
+
if (generation !== this.generation || options.signal?.aborted)
|
|
80
|
+
throw createWalletError.notConnected();
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
assertCurrent();
|
|
84
|
+
const network = options.network ?? session.account.network;
|
|
85
|
+
if (network && !adapterSupportsNetwork(this, network))
|
|
90
86
|
return null;
|
|
87
|
+
const externalProtocol = network && getNetworkFamily(network) !== "xrpl";
|
|
88
|
+
const context = options.protocolContext;
|
|
89
|
+
if (externalProtocol && (!context || context.protocol.family !== getNetworkFamily(network)
|
|
90
|
+
|| context.network.id !== network.id || context.network.networkId !== network.networkId
|
|
91
|
+
|| getNetworkFamily(context.network) !== getNetworkFamily(network)
|
|
92
|
+
|| context.network.networkType !== network.networkType || context.network.rpcUrl !== network.rpcUrl))
|
|
93
|
+
return null;
|
|
94
|
+
if (!await this.withAbort(() => this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500), options.signal))
|
|
95
|
+
return null;
|
|
96
|
+
assertCurrent();
|
|
97
|
+
const provider = this.getProvider();
|
|
98
|
+
const address = await this.withAbort(() => this.getCurrentAddress(provider), options.signal);
|
|
99
|
+
assertCurrent();
|
|
100
|
+
if (!address || address.accountAddress !== session.account.address)
|
|
101
|
+
return null;
|
|
102
|
+
let reported;
|
|
103
|
+
if (this.options.supportedChains) {
|
|
104
|
+
if (!network)
|
|
105
|
+
return null;
|
|
106
|
+
// Restore needs positive network evidence; unlike explicit connect it cannot use a configured-preset fallback.
|
|
107
|
+
reported = await this.readNetwork(provider, options.signal, assertCurrent);
|
|
108
|
+
const hint = getProviderHint(network, "gemwallet");
|
|
109
|
+
if (reported.result?.chain !== hint.chain || this.networkName(reported.result?.network) !== hint.network)
|
|
110
|
+
return null;
|
|
91
111
|
}
|
|
112
|
+
assertCurrent();
|
|
113
|
+
const account = { ...session.account, address: address.accountAddress, network,
|
|
114
|
+
...(externalProtocol ? { publicKey: undefined, networkType: this.networkName(reported?.result?.network) } : {}) };
|
|
115
|
+
this.account = account;
|
|
116
|
+
this.protocolContext = externalProtocol ? { protocol: context.protocol, network: network } : undefined;
|
|
117
|
+
return {
|
|
118
|
+
account,
|
|
119
|
+
session: { ...session, account, ...(externalProtocol ? {
|
|
120
|
+
metadata: { ...session.metadata, networkSource: "provider", providerNetworkAvailable: true }
|
|
121
|
+
} : {}) },
|
|
122
|
+
raw: { address: address.raw, network: reported }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return null;
|
|
92
127
|
}
|
|
93
|
-
return {
|
|
94
|
-
account: { ...session.account, address: address.accountAddress },
|
|
95
|
-
session: { ...session, account: { ...session.account, address: address.accountAddress } },
|
|
96
|
-
raw: address.raw
|
|
97
|
-
};
|
|
98
128
|
}
|
|
99
129
|
async signMessage(request) {
|
|
100
130
|
const generation = this.generation;
|
|
@@ -349,6 +379,8 @@ export class GemWalletAdapter extends BaseWalletAdapter {
|
|
|
349
379
|
return undefined;
|
|
350
380
|
try {
|
|
351
381
|
const raw = await provider.getAddress();
|
|
382
|
+
if (raw.type === "reject")
|
|
383
|
+
return undefined;
|
|
352
384
|
const accountAddress = raw.result?.address;
|
|
353
385
|
return accountAddress ? { accountAddress, raw } : undefined;
|
|
354
386
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrpl-wallet-kit/adapter-gemwallet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "GemWallet adapter for XRPL Wallet Kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@gemwallet/api": "^3.7.0",
|
|
25
|
-
"@xrpl-wallet-kit/core": "0.3.
|
|
25
|
+
"@xrpl-wallet-kit/core": "0.3.2"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|