@nibgate/sdk 0.2.15 → 0.2.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nibgate/sdk",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Framework-agnostic browser and server package for creator-owned gated content, unlock events, and receipts.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -113,12 +113,16 @@ export function createEvmGatewayUnlock(resource, options = {}) {
113
113
  async function checkout(input) {
114
114
  const evm = provider();
115
115
  if (!evm) throw new Error(options.noWalletMessage || 'Install or open an EVM wallet to continue.');
116
- if (!walletAddress) await connect();
116
+ // Always fetch the current wallet from MetaMask — the cached walletAddress
117
+ // might be stale if the user switched accounts after connecting.
118
+ const currentAccounts = await evm.request({ method: 'eth_accounts' }).catch(() => walletAddress ? [walletAddress] : []);
119
+ const currentAddress = Array.isArray(currentAccounts) && currentAccounts[0] ? currentAccounts[0] : (walletAddress || await connect());
120
+ if (currentAddress !== walletAddress) walletAddress = currentAddress;
117
121
  const gatewayWallet = await createCircleGatewayBrowserAdapter({
118
122
  network,
119
123
  signer: {
120
- address: walletAddress,
121
- signTypedData: (typedData) => evm.request({ method: 'eth_signTypedData_v4', params: [walletAddress, stringifyJson(typedData)] })
124
+ address: currentAddress,
125
+ signTypedData: (typedData) => evm.request({ method: 'eth_signTypedData_v4', params: [currentAddress, stringifyJson(typedData)] })
122
126
  },
123
127
  clientModule: options.circleClientModule
124
128
  });