@polkadot/extension-base 0.41.3-3 → 0.41.3-4
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.
|
@@ -48,15 +48,23 @@ describe('Extension', () => {
|
|
|
48
48
|
return new _Extension.default(state);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const createAccount = async
|
|
52
|
-
await extension.handle('id', 'pri(accounts.create.suri)', {
|
|
51
|
+
const createAccount = async type => {
|
|
52
|
+
await extension.handle('id', 'pri(accounts.create.suri)', type && type === 'ethereum' ? {
|
|
53
|
+
name: 'parent',
|
|
54
|
+
password,
|
|
55
|
+
suri,
|
|
56
|
+
type
|
|
57
|
+
} : {
|
|
53
58
|
name: 'parent',
|
|
54
59
|
password,
|
|
55
60
|
suri
|
|
56
61
|
}, {});
|
|
57
62
|
const {
|
|
58
63
|
address
|
|
59
|
-
} = await extension.handle('id', 'pri(seed.validate)', {
|
|
64
|
+
} = await extension.handle('id', 'pri(seed.validate)', type && type === 'ethereum' ? {
|
|
65
|
+
suri,
|
|
66
|
+
type
|
|
67
|
+
} : {
|
|
60
68
|
suri
|
|
61
69
|
}, {});
|
|
62
70
|
return address;
|
|
@@ -175,7 +183,7 @@ describe('Extension', () => {
|
|
|
175
183
|
nonce: '0x0000000000000000',
|
|
176
184
|
signedExtensions: ['CheckSpecVersion', 'CheckTxVersion', 'CheckGenesis', 'CheckMortality', 'CheckNonce', 'CheckWeight', 'ChargeTransactionPayment'],
|
|
177
185
|
specVersion: '0x00000026',
|
|
178
|
-
tip:
|
|
186
|
+
tip: '0x00000000000000000000000000000000',
|
|
179
187
|
transactionVersion: '0x00000005',
|
|
180
188
|
version: 4
|
|
181
189
|
};
|
|
@@ -195,6 +203,40 @@ describe('Extension', () => {
|
|
|
195
203
|
savePass: false
|
|
196
204
|
}, {})).resolves.toEqual(true);
|
|
197
205
|
});
|
|
206
|
+
test('signs with default signed extensions - ethereum', async () => {
|
|
207
|
+
const ethAddress = await createAccount('ethereum');
|
|
208
|
+
|
|
209
|
+
const ethPair = _uiKeyring.default.getPair(ethAddress);
|
|
210
|
+
|
|
211
|
+
ethPair.decodePkcs8(password);
|
|
212
|
+
const ethPayload = {
|
|
213
|
+
address: ethAddress,
|
|
214
|
+
blockHash: '0xf9fc354edc3ff49f43d5e2c14e3c609a0c4ba469ed091edf893d672993dc9bc0',
|
|
215
|
+
blockNumber: '0x00000393',
|
|
216
|
+
era: '0x3601',
|
|
217
|
+
genesisHash: '0xf9fc354edc3ff49f43d5e2c14e3c609a0c4ba469ed091edf893d672993dc9bc0',
|
|
218
|
+
method: '0x03003cd0a705a2dc65e5b1e1205896baa2be8a07c6e0070010a5d4e8',
|
|
219
|
+
nonce: '0x00000000',
|
|
220
|
+
signedExtensions: ['CheckSpecVersion', 'CheckTxVersion', 'CheckGenesis', 'CheckMortality', 'CheckNonce', 'CheckWeight', 'ChargeTransactionPayment'],
|
|
221
|
+
specVersion: '0x000003e9',
|
|
222
|
+
tip: '0x00000000000000000000000000000000',
|
|
223
|
+
transactionVersion: '0x00000002',
|
|
224
|
+
version: 4
|
|
225
|
+
};
|
|
226
|
+
const registry = new _types.TypeRegistry();
|
|
227
|
+
registry.setSignedExtensions(payload.signedExtensions);
|
|
228
|
+
const signatureExpected = registry.createType('ExtrinsicPayload', ethPayload, {
|
|
229
|
+
version: ethPayload.version
|
|
230
|
+
}).sign(ethPair);
|
|
231
|
+
tabs.handle('1615191860871.5', 'pub(extrinsic.sign)', ethPayload, 'http://localhost:3000', {}).then(result => {
|
|
232
|
+
expect(result === null || result === void 0 ? void 0 : result.signature).toEqual(signatureExpected.signature);
|
|
233
|
+
}).catch(err => console.log(err));
|
|
234
|
+
await expect(extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
|
|
235
|
+
id: state.allSignRequests[0].id,
|
|
236
|
+
password,
|
|
237
|
+
savePass: false
|
|
238
|
+
}, {})).resolves.toEqual(true);
|
|
239
|
+
});
|
|
198
240
|
test('signs with user extensions, known types', async () => {
|
|
199
241
|
const types = {};
|
|
200
242
|
const userExtensions = {
|
|
@@ -228,7 +270,7 @@ describe('Extension', () => {
|
|
|
228
270
|
nonce: '0x0000000000000000',
|
|
229
271
|
signedExtensions: ['MyUserExtension'],
|
|
230
272
|
specVersion: '0x00000026',
|
|
231
|
-
tip:
|
|
273
|
+
tip: '0x00000000000000000000000000000000',
|
|
232
274
|
transactionVersion: '0x00000005',
|
|
233
275
|
version: 4
|
|
234
276
|
};
|
|
@@ -34,15 +34,23 @@ describe('Extension', () => {
|
|
|
34
34
|
return new Extension(state);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const createAccount = async
|
|
38
|
-
await extension.handle('id', 'pri(accounts.create.suri)', {
|
|
37
|
+
const createAccount = async type => {
|
|
38
|
+
await extension.handle('id', 'pri(accounts.create.suri)', type && type === 'ethereum' ? {
|
|
39
|
+
name: 'parent',
|
|
40
|
+
password,
|
|
41
|
+
suri,
|
|
42
|
+
type
|
|
43
|
+
} : {
|
|
39
44
|
name: 'parent',
|
|
40
45
|
password,
|
|
41
46
|
suri
|
|
42
47
|
}, {});
|
|
43
48
|
const {
|
|
44
49
|
address
|
|
45
|
-
} = await extension.handle('id', 'pri(seed.validate)', {
|
|
50
|
+
} = await extension.handle('id', 'pri(seed.validate)', type && type === 'ethereum' ? {
|
|
51
|
+
suri,
|
|
52
|
+
type
|
|
53
|
+
} : {
|
|
46
54
|
suri
|
|
47
55
|
}, {});
|
|
48
56
|
return address;
|
|
@@ -158,7 +166,7 @@ describe('Extension', () => {
|
|
|
158
166
|
nonce: '0x0000000000000000',
|
|
159
167
|
signedExtensions: ['CheckSpecVersion', 'CheckTxVersion', 'CheckGenesis', 'CheckMortality', 'CheckNonce', 'CheckWeight', 'ChargeTransactionPayment'],
|
|
160
168
|
specVersion: '0x00000026',
|
|
161
|
-
tip:
|
|
169
|
+
tip: '0x00000000000000000000000000000000',
|
|
162
170
|
transactionVersion: '0x00000005',
|
|
163
171
|
version: 4
|
|
164
172
|
};
|
|
@@ -178,6 +186,38 @@ describe('Extension', () => {
|
|
|
178
186
|
savePass: false
|
|
179
187
|
}, {})).resolves.toEqual(true);
|
|
180
188
|
});
|
|
189
|
+
test('signs with default signed extensions - ethereum', async () => {
|
|
190
|
+
const ethAddress = await createAccount('ethereum');
|
|
191
|
+
const ethPair = keyring.getPair(ethAddress);
|
|
192
|
+
ethPair.decodePkcs8(password);
|
|
193
|
+
const ethPayload = {
|
|
194
|
+
address: ethAddress,
|
|
195
|
+
blockHash: '0xf9fc354edc3ff49f43d5e2c14e3c609a0c4ba469ed091edf893d672993dc9bc0',
|
|
196
|
+
blockNumber: '0x00000393',
|
|
197
|
+
era: '0x3601',
|
|
198
|
+
genesisHash: '0xf9fc354edc3ff49f43d5e2c14e3c609a0c4ba469ed091edf893d672993dc9bc0',
|
|
199
|
+
method: '0x03003cd0a705a2dc65e5b1e1205896baa2be8a07c6e0070010a5d4e8',
|
|
200
|
+
nonce: '0x00000000',
|
|
201
|
+
signedExtensions: ['CheckSpecVersion', 'CheckTxVersion', 'CheckGenesis', 'CheckMortality', 'CheckNonce', 'CheckWeight', 'ChargeTransactionPayment'],
|
|
202
|
+
specVersion: '0x000003e9',
|
|
203
|
+
tip: '0x00000000000000000000000000000000',
|
|
204
|
+
transactionVersion: '0x00000002',
|
|
205
|
+
version: 4
|
|
206
|
+
};
|
|
207
|
+
const registry = new TypeRegistry();
|
|
208
|
+
registry.setSignedExtensions(payload.signedExtensions);
|
|
209
|
+
const signatureExpected = registry.createType('ExtrinsicPayload', ethPayload, {
|
|
210
|
+
version: ethPayload.version
|
|
211
|
+
}).sign(ethPair);
|
|
212
|
+
tabs.handle('1615191860871.5', 'pub(extrinsic.sign)', ethPayload, 'http://localhost:3000', {}).then(result => {
|
|
213
|
+
expect(result === null || result === void 0 ? void 0 : result.signature).toEqual(signatureExpected.signature);
|
|
214
|
+
}).catch(err => console.log(err));
|
|
215
|
+
await expect(extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
|
|
216
|
+
id: state.allSignRequests[0].id,
|
|
217
|
+
password,
|
|
218
|
+
savePass: false
|
|
219
|
+
}, {})).resolves.toEqual(true);
|
|
220
|
+
});
|
|
181
221
|
test('signs with user extensions, known types', async () => {
|
|
182
222
|
const types = {};
|
|
183
223
|
const userExtensions = {
|
|
@@ -211,7 +251,7 @@ describe('Extension', () => {
|
|
|
211
251
|
nonce: '0x0000000000000000',
|
|
212
252
|
signedExtensions: ['MyUserExtension'],
|
|
213
253
|
specVersion: '0x00000026',
|
|
214
|
-
tip:
|
|
254
|
+
tip: '0x00000000000000000000000000000000',
|
|
215
255
|
transactionVersion: '0x00000005',
|
|
216
256
|
version: 4
|
|
217
257
|
};
|
package/package.json
CHANGED
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"type": "module",
|
|
17
|
-
"version": "0.41.3-
|
|
17
|
+
"version": "0.41.3-4",
|
|
18
18
|
"main": "index.js",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.16.3",
|
|
21
21
|
"@polkadot/api": "^6.11.1",
|
|
22
|
-
"@polkadot/extension-dapp": "^0.41.3-
|
|
23
|
-
"@polkadot/extension-inject": "^0.41.3-
|
|
22
|
+
"@polkadot/extension-dapp": "^0.41.3-4",
|
|
23
|
+
"@polkadot/extension-inject": "^0.41.3-4",
|
|
24
24
|
"@polkadot/keyring": "^8.1.2",
|
|
25
25
|
"@polkadot/phishing": "^0.6.510",
|
|
26
26
|
"@polkadot/ui-keyring": "^0.87.5"
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED