@dynamic-labs/starknet 4.87.2 → 4.88.0
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/CHANGELOG.md +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/StarknetWalletConnector.cjs +7 -3
- package/src/StarknetWalletConnector.js +7 -3
- package/src/utils/normalizeStarknetAddress.cjs +28 -0
- package/src/utils/normalizeStarknetAddress.d.ts +14 -0
- package/src/utils/normalizeStarknetAddress.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.88.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.87.2...v4.88.0) (2026-06-04)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **waas:** log out on iframe 401 ([#11456](https://github.com/dynamic-labs/dynamic-auth/issues/11456)) ([81b0161](https://github.com/dynamic-labs/dynamic-auth/commit/81b01617810af8f7f996fdbf406e020b9f98272b))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **starknet:** zero-pad addresses returned by wallet connectors ([#11303](https://github.com/dynamic-labs/dynamic-auth/issues/11303)) ([ef5cda5](https://github.com/dynamic-labs/dynamic-auth/commit/ef5cda5a9933443195b3bd336db8947c2ec050b7))
|
|
13
|
+
|
|
2
14
|
### [4.87.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.87.1...v4.87.2) (2026-06-03)
|
|
3
15
|
|
|
4
16
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/starknet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.88.0",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"starknetkit": "2.10.4",
|
|
25
25
|
"text-encoding": "0.7.0",
|
|
26
26
|
"@dynamic-labs/sdk-api-core": "0.0.1015",
|
|
27
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
28
|
-
"@dynamic-labs/logger": "4.
|
|
29
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
30
|
-
"@dynamic-labs/starknet-core": "4.
|
|
31
|
-
"@dynamic-labs/types": "4.
|
|
32
|
-
"@dynamic-labs/utils": "4.
|
|
33
|
-
"@dynamic-labs/wallet-book": "4.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
27
|
+
"@dynamic-labs/assert-package-version": "4.88.0",
|
|
28
|
+
"@dynamic-labs/logger": "4.88.0",
|
|
29
|
+
"@dynamic-labs/rpc-providers": "4.88.0",
|
|
30
|
+
"@dynamic-labs/starknet-core": "4.88.0",
|
|
31
|
+
"@dynamic-labs/types": "4.88.0",
|
|
32
|
+
"@dynamic-labs/utils": "4.88.0",
|
|
33
|
+
"@dynamic-labs/wallet-book": "4.88.0",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "4.88.0",
|
|
35
35
|
"assert": "2.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {}
|
|
@@ -11,6 +11,7 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
11
11
|
var constants = require('./constants.cjs');
|
|
12
12
|
var ethereumContractAbi = require('./ethereumContractAbi.cjs');
|
|
13
13
|
var convertors = require('./utils/convertors.cjs');
|
|
14
|
+
var normalizeStarknetAddress = require('./utils/normalizeStarknetAddress.cjs');
|
|
14
15
|
var StarknetWallet = require('./wallet/StarknetWallet.cjs');
|
|
15
16
|
|
|
16
17
|
class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
@@ -52,7 +53,9 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
52
53
|
return undefined;
|
|
53
54
|
}
|
|
54
55
|
this.wallet = wallet;
|
|
55
|
-
this.walletData = data
|
|
56
|
+
this.walletData = Object.assign(Object.assign({}, data), { account: data.account
|
|
57
|
+
? normalizeStarknetAddress.normalizeStarknetAddress(data.account)
|
|
58
|
+
: data.account });
|
|
56
59
|
this.setupEventListeners();
|
|
57
60
|
return this.walletData.account;
|
|
58
61
|
});
|
|
@@ -159,11 +162,12 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
159
162
|
}
|
|
160
163
|
const [address] = accounts;
|
|
161
164
|
if (address) {
|
|
165
|
+
const normalizedAddress = normalizeStarknetAddress.normalizeStarknetAddress(address.toString());
|
|
162
166
|
this.walletData = {
|
|
163
|
-
account:
|
|
167
|
+
account: normalizedAddress,
|
|
164
168
|
chainId: (_a = this.walletData) === null || _a === void 0 ? void 0 : _a.chainId,
|
|
165
169
|
};
|
|
166
|
-
this.emit('accountChange', { accounts: [
|
|
170
|
+
this.emit('accountChange', { accounts: [normalizedAddress] });
|
|
167
171
|
}
|
|
168
172
|
});
|
|
169
173
|
this.handleNetworkChange = (chainId) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -7,6 +7,7 @@ import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
|
7
7
|
import { ETH_STARKNET_ADDRESS } from './constants.js';
|
|
8
8
|
import ETH_CONTRACT_ABI from './ethereumContractAbi.js';
|
|
9
9
|
import { formatTypedDataMessage } from './utils/convertors.js';
|
|
10
|
+
import { normalizeStarknetAddress } from './utils/normalizeStarknetAddress.js';
|
|
10
11
|
import { StarknetWallet } from './wallet/StarknetWallet.js';
|
|
11
12
|
|
|
12
13
|
class StarknetWalletConnector extends WalletConnectorBase {
|
|
@@ -48,7 +49,9 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
48
49
|
return undefined;
|
|
49
50
|
}
|
|
50
51
|
this.wallet = wallet;
|
|
51
|
-
this.walletData = data
|
|
52
|
+
this.walletData = Object.assign(Object.assign({}, data), { account: data.account
|
|
53
|
+
? normalizeStarknetAddress(data.account)
|
|
54
|
+
: data.account });
|
|
52
55
|
this.setupEventListeners();
|
|
53
56
|
return this.walletData.account;
|
|
54
57
|
});
|
|
@@ -155,11 +158,12 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
155
158
|
}
|
|
156
159
|
const [address] = accounts;
|
|
157
160
|
if (address) {
|
|
161
|
+
const normalizedAddress = normalizeStarknetAddress(address.toString());
|
|
158
162
|
this.walletData = {
|
|
159
|
-
account:
|
|
163
|
+
account: normalizedAddress,
|
|
160
164
|
chainId: (_a = this.walletData) === null || _a === void 0 ? void 0 : _a.chainId,
|
|
161
165
|
};
|
|
162
|
-
this.emit('accountChange', { accounts: [
|
|
166
|
+
this.emit('accountChange', { accounts: [normalizedAddress] });
|
|
163
167
|
}
|
|
164
168
|
});
|
|
165
169
|
this.handleNetworkChange = (chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a Starknet address to its canonical 66-character form
|
|
8
|
+
* (`0x` + 64 hex digits, zero-padded on the left).
|
|
9
|
+
*
|
|
10
|
+
* Some wallet connectors (e.g. Ready/Argent X's `wallet_requestAccounts` RPC)
|
|
11
|
+
* return Starknet addresses without leading zero padding. The unpadded and
|
|
12
|
+
* padded forms are numerically identical, but mixing the two causes user
|
|
13
|
+
* confusion and breaks naive string comparisons against systems that use the
|
|
14
|
+
* canonical form (e.g. block explorers and the wallet's own UI).
|
|
15
|
+
*
|
|
16
|
+
* The original hex digit casing is preserved so checksummed representations
|
|
17
|
+
* surfaced by the wallet are not lost.
|
|
18
|
+
*/
|
|
19
|
+
const normalizeStarknetAddress = (address) => {
|
|
20
|
+
const hasPrefix = address.startsWith('0x') || address.startsWith('0X');
|
|
21
|
+
const hex = hasPrefix ? address.slice(2) : address;
|
|
22
|
+
if (hex.length >= 64) {
|
|
23
|
+
return hasPrefix ? address : `0x${hex}`;
|
|
24
|
+
}
|
|
25
|
+
return `0x${hex.padStart(64, '0')}`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.normalizeStarknetAddress = normalizeStarknetAddress;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a Starknet address to its canonical 66-character form
|
|
3
|
+
* (`0x` + 64 hex digits, zero-padded on the left).
|
|
4
|
+
*
|
|
5
|
+
* Some wallet connectors (e.g. Ready/Argent X's `wallet_requestAccounts` RPC)
|
|
6
|
+
* return Starknet addresses without leading zero padding. The unpadded and
|
|
7
|
+
* padded forms are numerically identical, but mixing the two causes user
|
|
8
|
+
* confusion and breaks naive string comparisons against systems that use the
|
|
9
|
+
* canonical form (e.g. block explorers and the wallet's own UI).
|
|
10
|
+
*
|
|
11
|
+
* The original hex digit casing is preserved so checksummed representations
|
|
12
|
+
* surfaced by the wallet are not lost.
|
|
13
|
+
*/
|
|
14
|
+
export declare const normalizeStarknetAddress: (address: string) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a Starknet address to its canonical 66-character form
|
|
4
|
+
* (`0x` + 64 hex digits, zero-padded on the left).
|
|
5
|
+
*
|
|
6
|
+
* Some wallet connectors (e.g. Ready/Argent X's `wallet_requestAccounts` RPC)
|
|
7
|
+
* return Starknet addresses without leading zero padding. The unpadded and
|
|
8
|
+
* padded forms are numerically identical, but mixing the two causes user
|
|
9
|
+
* confusion and breaks naive string comparisons against systems that use the
|
|
10
|
+
* canonical form (e.g. block explorers and the wallet's own UI).
|
|
11
|
+
*
|
|
12
|
+
* The original hex digit casing is preserved so checksummed representations
|
|
13
|
+
* surfaced by the wallet are not lost.
|
|
14
|
+
*/
|
|
15
|
+
const normalizeStarknetAddress = (address) => {
|
|
16
|
+
const hasPrefix = address.startsWith('0x') || address.startsWith('0X');
|
|
17
|
+
const hex = hasPrefix ? address.slice(2) : address;
|
|
18
|
+
if (hex.length >= 64) {
|
|
19
|
+
return hasPrefix ? address : `0x${hex}`;
|
|
20
|
+
}
|
|
21
|
+
return `0x${hex.padStart(64, '0')}`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { normalizeStarknetAddress };
|