@dfns/lib-polymesh 0.7.2-beta.1 → 0.7.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/index.d.ts +0 -3
- package/index.js +11 -8
- package/package.json +3 -4
package/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { DfnsApiClient } from '@dfns/sdk';
|
|
2
2
|
import { PolkadotSigner, SignerPayloadRaw, SignerPayloadJSON, SignerResult, SigningManager } from '@polymeshassociation/signing-manager-types';
|
|
3
|
-
import { Registry } from '@polkadot/types/types';
|
|
4
3
|
export type DfnsWalletOptions = {
|
|
5
4
|
walletId: string;
|
|
6
5
|
dfnsClient: DfnsApiClient;
|
|
7
|
-
registry: Registry;
|
|
8
6
|
};
|
|
9
7
|
export declare class DfnsSigningManager implements SigningManager {
|
|
10
8
|
private externalSigner;
|
|
@@ -27,7 +25,6 @@ export declare class DfnsWallet implements PolkadotSigner {
|
|
|
27
25
|
private id;
|
|
28
26
|
private readonly dfnsClient;
|
|
29
27
|
private readonly walletId;
|
|
30
|
-
private readonly registry;
|
|
31
28
|
private constructor();
|
|
32
29
|
static init(options: DfnsWalletOptions): Promise<DfnsWallet>;
|
|
33
30
|
signRaw(raw: SignerPayloadRaw): Promise<SignerResult>;
|
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DfnsWallet = exports.DfnsSigningManager = void 0;
|
|
4
4
|
const sdk_1 = require("@dfns/sdk");
|
|
5
|
-
const types_1 = require("@polkadot/types");
|
|
6
5
|
const Ss58PrefixMap = {
|
|
7
6
|
['Polymesh']: 12,
|
|
8
7
|
['PolymeshTestnet']: 42,
|
|
@@ -49,7 +48,6 @@ class DfnsWallet {
|
|
|
49
48
|
this.network = network;
|
|
50
49
|
this.dfnsClient = options.dfnsClient;
|
|
51
50
|
this.walletId = options.walletId;
|
|
52
|
-
this.registry = options.registry;
|
|
53
51
|
}
|
|
54
52
|
static async init(options) {
|
|
55
53
|
const { walletId, dfnsClient } = options;
|
|
@@ -71,16 +69,12 @@ class DfnsWallet {
|
|
|
71
69
|
}
|
|
72
70
|
async signPayload(signerPayload) {
|
|
73
71
|
this.validateAddress(signerPayload.address);
|
|
74
|
-
const { transactionVersion, specVersion, ...rest } = signerPayload;
|
|
75
|
-
const genericPayload = new types_1.GenericSignerPayload(this.registry, {
|
|
76
|
-
...rest,
|
|
77
|
-
runtimeVersion: { specVersion, transactionVersion },
|
|
78
|
-
});
|
|
79
72
|
const response = await this.dfnsClient.wallets.generateSignature({
|
|
80
73
|
walletId: this.walletId,
|
|
81
74
|
body: {
|
|
82
75
|
kind: 'SignerPayload',
|
|
83
|
-
payload
|
|
76
|
+
// remove null values from the payload to avoid issues with the DFNS API
|
|
77
|
+
payload: sanitizePayload(signerPayload)
|
|
84
78
|
}
|
|
85
79
|
});
|
|
86
80
|
assertSignResponseSuccessful(response);
|
|
@@ -110,3 +104,12 @@ class DfnsWallet {
|
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
106
|
exports.DfnsWallet = DfnsWallet;
|
|
107
|
+
const sanitizePayload = (payload) => {
|
|
108
|
+
const result = { ...payload };
|
|
109
|
+
for (const key in result) {
|
|
110
|
+
if (result[key] === null) {
|
|
111
|
+
result[key] = undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfns/lib-polymesh",
|
|
3
|
-
"version": "0.7.2
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@polkadot/api": "11.
|
|
5
|
+
"@polkadot/api": "^11.0.0",
|
|
6
6
|
"@polymeshassociation/signing-manager-types": "3.4.0",
|
|
7
|
-
"@dfns/sdk": "0.7.2
|
|
7
|
+
"@dfns/sdk": "0.7.2"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@polkadot/types": "11.2.1",
|
|
11
10
|
"@polkadot/util": "12.6.2",
|
|
12
11
|
"buffer": "6.0.3",
|
|
13
12
|
"cross-fetch": "3.1.6"
|