@frequency-chain/ethereum-utils 0.0.0-775e5c → 0.0.0-7c7edc
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/browser/frequency-ethereum-utils.esm.min.js +164 -170
- package/browser/frequency-ethereum-utils.umd.min.js +164 -170
- package/cjs/signature.definitions.js +1 -1
- package/cjs/signature.js +10 -10
- package/esm/signature.definitions.js +1 -1
- package/esm/signature.js +10 -10
- package/index.d.ts +3 -3
- package/package.json +4 -4
- package/payloads.d.ts +1 -1
- package/signature.d.ts +5 -5
package/cjs/signature.js
CHANGED
|
@@ -171,9 +171,9 @@ function createAddKeyData(msaId, newPublicKey, expirationBlock) {
|
|
|
171
171
|
* @param authorizedPublicKey 32 bytes public key to authorize in hex or Uint8Array
|
|
172
172
|
* @param expirationBlock Block number after which this payload is invalid
|
|
173
173
|
*/
|
|
174
|
-
function createAuthorizedKeyData(msaId,
|
|
174
|
+
function createAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock) {
|
|
175
175
|
const parsedMsaId = typeof msaId === 'string' ? msaId : `${msaId}`;
|
|
176
|
-
const parsedNewPublicKey = typeof
|
|
176
|
+
const parsedNewPublicKey = typeof authorizedPublicKey === 'object' ? (0, util_1.u8aToHex)(authorizedPublicKey) : authorizedPublicKey;
|
|
177
177
|
(0, utils_js_1.assert)((0, utils_js_1.isValidUint64String)(parsedMsaId), 'msaId should be a valid uint64');
|
|
178
178
|
(0, utils_js_1.assert)((0, utils_js_1.isValidUint32)(expirationBlock), 'expiration should be a valid uint32');
|
|
179
179
|
(0, utils_js_1.assert)((0, utils_js_1.isHexString)(parsedNewPublicKey), 'newPublicKey should be valid hex');
|
|
@@ -188,19 +188,19 @@ function createAuthorizedKeyData(msaId, newPublicKey, expirationBlock) {
|
|
|
188
188
|
* Build an AddProvider payload for signature.
|
|
189
189
|
*
|
|
190
190
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
191
|
-
* @param
|
|
191
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
192
192
|
* @param expirationBlock Block number after which this payload is invalid
|
|
193
193
|
*/
|
|
194
|
-
function createAddProvider(authorizedMsaId,
|
|
194
|
+
function createAddProvider(authorizedMsaId, intentIds, expirationBlock) {
|
|
195
195
|
(0, utils_js_1.assert)((0, utils_js_1.isValidUint64String)(authorizedMsaId), 'authorizedMsaId should be a valid uint64');
|
|
196
196
|
(0, utils_js_1.assert)((0, utils_js_1.isValidUint32)(expirationBlock), 'expiration should be a valid uint32');
|
|
197
|
-
|
|
198
|
-
(0, utils_js_1.assert)((0, utils_js_1.isValidUint16)(
|
|
197
|
+
intentIds.forEach((intentId) => {
|
|
198
|
+
(0, utils_js_1.assert)((0, utils_js_1.isValidUint16)(intentId), 'intentId should be a valid uint16');
|
|
199
199
|
});
|
|
200
200
|
return {
|
|
201
201
|
type: 'AddProvider',
|
|
202
202
|
authorizedMsaId: authorizedMsaId.toString(),
|
|
203
|
-
|
|
203
|
+
intentIds,
|
|
204
204
|
expiration: expirationBlock,
|
|
205
205
|
};
|
|
206
206
|
}
|
|
@@ -396,12 +396,12 @@ function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, ex
|
|
|
396
396
|
* Returns the EIP-712 browser request for a AddProvider for signing.
|
|
397
397
|
*
|
|
398
398
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
399
|
-
* @param
|
|
399
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
400
400
|
* @param expirationBlock Block number after which this payload is invalid
|
|
401
401
|
* @param domain
|
|
402
402
|
*/
|
|
403
|
-
function getEip712BrowserRequestAddProvider(authorizedMsaId,
|
|
404
|
-
const message = createAddProvider(authorizedMsaId,
|
|
403
|
+
function getEip712BrowserRequestAddProvider(authorizedMsaId, intentIds, expirationBlock, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
404
|
+
const message = createAddProvider(authorizedMsaId, intentIds, expirationBlock);
|
|
405
405
|
const normalized = normalizePayload(message);
|
|
406
406
|
return createEip712Payload(signature_definitions_js_1.ADD_PROVIDER_DEFINITION, message.type, domain, normalized);
|
|
407
407
|
}
|
package/esm/signature.js
CHANGED
|
@@ -142,9 +142,9 @@ export function createAddKeyData(msaId, newPublicKey, expirationBlock) {
|
|
|
142
142
|
* @param authorizedPublicKey 32 bytes public key to authorize in hex or Uint8Array
|
|
143
143
|
* @param expirationBlock Block number after which this payload is invalid
|
|
144
144
|
*/
|
|
145
|
-
export function createAuthorizedKeyData(msaId,
|
|
145
|
+
export function createAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock) {
|
|
146
146
|
const parsedMsaId = typeof msaId === 'string' ? msaId : `${msaId}`;
|
|
147
|
-
const parsedNewPublicKey = typeof
|
|
147
|
+
const parsedNewPublicKey = typeof authorizedPublicKey === 'object' ? u8aToHex(authorizedPublicKey) : authorizedPublicKey;
|
|
148
148
|
assert(isValidUint64String(parsedMsaId), 'msaId should be a valid uint64');
|
|
149
149
|
assert(isValidUint32(expirationBlock), 'expiration should be a valid uint32');
|
|
150
150
|
assert(isHexString(parsedNewPublicKey), 'newPublicKey should be valid hex');
|
|
@@ -159,19 +159,19 @@ export function createAuthorizedKeyData(msaId, newPublicKey, expirationBlock) {
|
|
|
159
159
|
* Build an AddProvider payload for signature.
|
|
160
160
|
*
|
|
161
161
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
162
|
-
* @param
|
|
162
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
163
163
|
* @param expirationBlock Block number after which this payload is invalid
|
|
164
164
|
*/
|
|
165
|
-
export function createAddProvider(authorizedMsaId,
|
|
165
|
+
export function createAddProvider(authorizedMsaId, intentIds, expirationBlock) {
|
|
166
166
|
assert(isValidUint64String(authorizedMsaId), 'authorizedMsaId should be a valid uint64');
|
|
167
167
|
assert(isValidUint32(expirationBlock), 'expiration should be a valid uint32');
|
|
168
|
-
|
|
169
|
-
assert(isValidUint16(
|
|
168
|
+
intentIds.forEach((intentId) => {
|
|
169
|
+
assert(isValidUint16(intentId), 'intentId should be a valid uint16');
|
|
170
170
|
});
|
|
171
171
|
return {
|
|
172
172
|
type: 'AddProvider',
|
|
173
173
|
authorizedMsaId: authorizedMsaId.toString(),
|
|
174
|
-
|
|
174
|
+
intentIds,
|
|
175
175
|
expiration: expirationBlock,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
@@ -367,12 +367,12 @@ export function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublic
|
|
|
367
367
|
* Returns the EIP-712 browser request for a AddProvider for signing.
|
|
368
368
|
*
|
|
369
369
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
370
|
-
* @param
|
|
370
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
371
371
|
* @param expirationBlock Block number after which this payload is invalid
|
|
372
372
|
* @param domain
|
|
373
373
|
*/
|
|
374
|
-
export function getEip712BrowserRequestAddProvider(authorizedMsaId,
|
|
375
|
-
const message = createAddProvider(authorizedMsaId,
|
|
374
|
+
export function getEip712BrowserRequestAddProvider(authorizedMsaId, intentIds, expirationBlock, domain = EIP712_DOMAIN_MAINNET) {
|
|
375
|
+
const message = createAddProvider(authorizedMsaId, intentIds, expirationBlock);
|
|
376
376
|
const normalized = normalizePayload(message);
|
|
377
377
|
return createEip712Payload(ADD_PROVIDER_DEFINITION, message.type, domain, normalized);
|
|
378
378
|
}
|
package/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare const _default: {
|
|
|
7
7
|
sign(secretKey: payloads.HexString, payload: payloads.SupportedPayload, chain: payloads.ChainType): Promise<payloads.EcdsaSignature>;
|
|
8
8
|
verifySignature(ethereumAddress: payloads.HexString, signature: payloads.HexString, payload: payloads.SupportedPayload, chain: payloads.ChainType): boolean;
|
|
9
9
|
createAddKeyData(msaId: string | bigint, newPublicKey: payloads.HexString | Uint8Array, expirationBlock: number): payloads.AddKeyData;
|
|
10
|
-
createAuthorizedKeyData(msaId: string | bigint,
|
|
11
|
-
createAddProvider(authorizedMsaId: string | bigint,
|
|
10
|
+
createAuthorizedKeyData(msaId: string | bigint, authorizedPublicKey: payloads.HexString | Uint8Array, expirationBlock: number): payloads.AuthorizedKeyData;
|
|
11
|
+
createAddProvider(authorizedMsaId: string | bigint, intentIds: number[], expirationBlock: number): payloads.AddProvider;
|
|
12
12
|
createRecoveryCommitmentPayload(recoveryCommitment: payloads.HexString, expirationBlock: number): payloads.RecoveryCommitmentPayload;
|
|
13
13
|
createClaimHandlePayload(handle: string, expirationBlock: number): payloads.ClaimHandlePayload;
|
|
14
14
|
createPasskeyPublicKey(publicKey: payloads.HexString | Uint8Array): payloads.PasskeyPublicKey;
|
|
@@ -21,7 +21,7 @@ declare const _default: {
|
|
|
21
21
|
createSiwfLoginRequestPayload(message: string): payloads.SiwfLoginRequestPayload;
|
|
22
22
|
getEip712BrowserRequestAddKeyData(msaId: string | bigint, newPublicKey: payloads.HexString | Uint8Array, expirationBlock: number, domain?: payloads.EipDomainPayload): unknown;
|
|
23
23
|
getEip712BrowserRequestAuthorizedKeyData(msaId: string | bigint, authorizedPublicKey: payloads.HexString | Uint8Array, expirationBlock: number, domain?: payloads.EipDomainPayload): unknown;
|
|
24
|
-
getEip712BrowserRequestAddProvider(authorizedMsaId: string | bigint,
|
|
24
|
+
getEip712BrowserRequestAddProvider(authorizedMsaId: string | bigint, intentIds: number[], expirationBlock: number, domain?: payloads.EipDomainPayload): unknown;
|
|
25
25
|
getEip712BrowserRequestRecoveryCommitmentPayload(recoveryCommitment: payloads.HexString, expirationBlock: number, domain?: payloads.EipDomainPayload): unknown;
|
|
26
26
|
getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId: number, pageId: number, targetHash: number, expiration: number, payload: payloads.HexString | Uint8Array, domain?: payloads.EipDomainPayload): unknown;
|
|
27
27
|
getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId: number, pageId: number, targetHash: number, expiration: number, domain?: payloads.EipDomainPayload): unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frequency-chain/ethereum-utils",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-7c7edc",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/frequency-chain/frequency/issues"
|
|
6
6
|
},
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"author": "frequency-chain",
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@polkadot/api": "16.4.
|
|
19
|
-
"@polkadot/util": "13.5.
|
|
18
|
+
"@polkadot/api": "16.4.8",
|
|
19
|
+
"@polkadot/util": "13.5.7",
|
|
20
20
|
"ethers": "6.15.0"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@rollup/rollup-linux-x64-gnu": "4.
|
|
23
|
+
"@rollup/rollup-linux-x64-gnu": "4.52.4"
|
|
24
24
|
},
|
|
25
25
|
"module": "./esm/index.js",
|
|
26
26
|
"types": "index.d.ts",
|
package/payloads.d.ts
CHANGED
package/signature.d.ts
CHANGED
|
@@ -31,15 +31,15 @@ export declare function createAddKeyData(msaId: string | bigint, newPublicKey: H
|
|
|
31
31
|
* @param authorizedPublicKey 32 bytes public key to authorize in hex or Uint8Array
|
|
32
32
|
* @param expirationBlock Block number after which this payload is invalid
|
|
33
33
|
*/
|
|
34
|
-
export declare function createAuthorizedKeyData(msaId: string | bigint,
|
|
34
|
+
export declare function createAuthorizedKeyData(msaId: string | bigint, authorizedPublicKey: HexString | Uint8Array, expirationBlock: number): AuthorizedKeyData;
|
|
35
35
|
/**
|
|
36
36
|
* Build an AddProvider payload for signature.
|
|
37
37
|
*
|
|
38
38
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
39
|
-
* @param
|
|
39
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
40
40
|
* @param expirationBlock Block number after which this payload is invalid
|
|
41
41
|
*/
|
|
42
|
-
export declare function createAddProvider(authorizedMsaId: string | bigint,
|
|
42
|
+
export declare function createAddProvider(authorizedMsaId: string | bigint, intentIds: number[], expirationBlock: number): AddProvider;
|
|
43
43
|
/**
|
|
44
44
|
* Build a RecoveryCommitmentPayload for signature.
|
|
45
45
|
*
|
|
@@ -136,11 +136,11 @@ export declare function getEip712BrowserRequestAuthorizedKeyData(msaId: string |
|
|
|
136
136
|
* Returns the EIP-712 browser request for a AddProvider for signing.
|
|
137
137
|
*
|
|
138
138
|
* @param authorizedMsaId MSA ID (uint64) that will be granted provider rights
|
|
139
|
-
* @param
|
|
139
|
+
* @param intentIds One or more schema IDs (uint16) the provider may use
|
|
140
140
|
* @param expirationBlock Block number after which this payload is invalid
|
|
141
141
|
* @param domain
|
|
142
142
|
*/
|
|
143
|
-
export declare function getEip712BrowserRequestAddProvider(authorizedMsaId: string | bigint,
|
|
143
|
+
export declare function getEip712BrowserRequestAddProvider(authorizedMsaId: string | bigint, intentIds: number[], expirationBlock: number, domain?: EipDomainPayload): unknown;
|
|
144
144
|
/**
|
|
145
145
|
* Returns the EIP-712 browser request for a RecoveryCommitmentPayload for signing.
|
|
146
146
|
*
|