@dynamic-labs-wallet/svm 0.0.126 → 0.0.127
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.cjs.js +37 -22
- package/index.esm.js +37 -22
- package/package.json +3 -2
- package/src/svm/client.d.ts +2 -0
- package/src/svm/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -125,31 +125,17 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
125
125
|
walletOperation: browser.WalletOperation.SIGN_TRANSACTION,
|
|
126
126
|
signedSessionId
|
|
127
127
|
});
|
|
128
|
-
const transactionBytes = new Uint8Array(Buffer.from(transaction, 'hex'));
|
|
129
|
-
const deserializedTransaction = web3_js.VersionedMessage.deserialize(transactionBytes);
|
|
130
|
-
const transaction2 = new web3_js.VersionedTransaction(deserializedTransaction);
|
|
131
|
-
const serializedTransaction = transaction2.serialize();
|
|
132
|
-
const base58SerializedTransaction = bs58.encode(serializedTransaction);
|
|
133
128
|
try {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
const base58SerializedTransaction = this.prepareTransactionForSigning(transaction);
|
|
130
|
+
const signParams = this.buildSignParams({
|
|
131
|
+
transaction,
|
|
132
|
+
senderAddress,
|
|
138
133
|
password,
|
|
139
134
|
signedSessionId,
|
|
140
|
-
mfaToken
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
svmTransaction: {
|
|
145
|
-
chainId,
|
|
146
|
-
method: 'signAndSendTransaction',
|
|
147
|
-
serializedTransactions: [
|
|
148
|
-
base58SerializedTransaction
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
135
|
+
mfaToken,
|
|
136
|
+
chainId,
|
|
137
|
+
base58SerializedTransaction
|
|
138
|
+
});
|
|
153
139
|
const signatureEd25519 = await this.sign(signParams);
|
|
154
140
|
if (!signatureEd25519) {
|
|
155
141
|
throw new Error('Signature is undefined');
|
|
@@ -163,6 +149,35 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
163
149
|
throw error;
|
|
164
150
|
}
|
|
165
151
|
}
|
|
152
|
+
prepareTransactionForSigning(transaction) {
|
|
153
|
+
const transactionBytes = new Uint8Array(Buffer.from(transaction, 'hex'));
|
|
154
|
+
const deserializedTransaction = web3_js.VersionedMessage.deserialize(transactionBytes);
|
|
155
|
+
const versionedTransaction = new web3_js.VersionedTransaction(deserializedTransaction);
|
|
156
|
+
const serializedTransaction = versionedTransaction.serialize();
|
|
157
|
+
return bs58.encode(serializedTransaction);
|
|
158
|
+
}
|
|
159
|
+
buildSignParams({ transaction, senderAddress, password, signedSessionId, mfaToken, chainId, base58SerializedTransaction }) {
|
|
160
|
+
const signParams = {
|
|
161
|
+
message: transaction,
|
|
162
|
+
accountAddress: senderAddress,
|
|
163
|
+
chainName: this.chainName,
|
|
164
|
+
password,
|
|
165
|
+
signedSessionId,
|
|
166
|
+
mfaToken
|
|
167
|
+
};
|
|
168
|
+
if (chainId !== undefined) {
|
|
169
|
+
signParams.context = {
|
|
170
|
+
svmTransaction: {
|
|
171
|
+
chainId,
|
|
172
|
+
method: 'signAndSendTransaction',
|
|
173
|
+
serializedTransactions: [
|
|
174
|
+
base58SerializedTransaction
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return signParams;
|
|
180
|
+
}
|
|
166
181
|
/**
|
|
167
182
|
* Exports the private key for a given account address
|
|
168
183
|
*
|
package/index.esm.js
CHANGED
|
@@ -123,31 +123,17 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
123
123
|
walletOperation: WalletOperation.SIGN_TRANSACTION,
|
|
124
124
|
signedSessionId
|
|
125
125
|
});
|
|
126
|
-
const transactionBytes = new Uint8Array(Buffer.from(transaction, 'hex'));
|
|
127
|
-
const deserializedTransaction = VersionedMessage.deserialize(transactionBytes);
|
|
128
|
-
const transaction2 = new VersionedTransaction(deserializedTransaction);
|
|
129
|
-
const serializedTransaction = transaction2.serialize();
|
|
130
|
-
const base58SerializedTransaction = bs58.encode(serializedTransaction);
|
|
131
126
|
try {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
const base58SerializedTransaction = this.prepareTransactionForSigning(transaction);
|
|
128
|
+
const signParams = this.buildSignParams({
|
|
129
|
+
transaction,
|
|
130
|
+
senderAddress,
|
|
136
131
|
password,
|
|
137
132
|
signedSessionId,
|
|
138
|
-
mfaToken
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
svmTransaction: {
|
|
143
|
-
chainId,
|
|
144
|
-
method: 'signAndSendTransaction',
|
|
145
|
-
serializedTransactions: [
|
|
146
|
-
base58SerializedTransaction
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
133
|
+
mfaToken,
|
|
134
|
+
chainId,
|
|
135
|
+
base58SerializedTransaction
|
|
136
|
+
});
|
|
151
137
|
const signatureEd25519 = await this.sign(signParams);
|
|
152
138
|
if (!signatureEd25519) {
|
|
153
139
|
throw new Error('Signature is undefined');
|
|
@@ -161,6 +147,35 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
161
147
|
throw error;
|
|
162
148
|
}
|
|
163
149
|
}
|
|
150
|
+
prepareTransactionForSigning(transaction) {
|
|
151
|
+
const transactionBytes = new Uint8Array(Buffer.from(transaction, 'hex'));
|
|
152
|
+
const deserializedTransaction = VersionedMessage.deserialize(transactionBytes);
|
|
153
|
+
const versionedTransaction = new VersionedTransaction(deserializedTransaction);
|
|
154
|
+
const serializedTransaction = versionedTransaction.serialize();
|
|
155
|
+
return bs58.encode(serializedTransaction);
|
|
156
|
+
}
|
|
157
|
+
buildSignParams({ transaction, senderAddress, password, signedSessionId, mfaToken, chainId, base58SerializedTransaction }) {
|
|
158
|
+
const signParams = {
|
|
159
|
+
message: transaction,
|
|
160
|
+
accountAddress: senderAddress,
|
|
161
|
+
chainName: this.chainName,
|
|
162
|
+
password,
|
|
163
|
+
signedSessionId,
|
|
164
|
+
mfaToken
|
|
165
|
+
};
|
|
166
|
+
if (chainId !== undefined) {
|
|
167
|
+
signParams.context = {
|
|
168
|
+
svmTransaction: {
|
|
169
|
+
chainId,
|
|
170
|
+
method: 'signAndSendTransaction',
|
|
171
|
+
serializedTransactions: [
|
|
172
|
+
base58SerializedTransaction
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return signParams;
|
|
178
|
+
}
|
|
164
179
|
/**
|
|
165
180
|
* Exports the private key for a given account address
|
|
166
181
|
*
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/svm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.127",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "0.0.127",
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "^0.0.745",
|
|
8
9
|
"@solana/web3.js": "^1.98.2",
|
|
9
10
|
"bs58": "^6.0.0"
|
|
10
11
|
},
|
package/src/svm/client.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
42
42
|
mfaToken?: string;
|
|
43
43
|
chainId?: string;
|
|
44
44
|
}): Promise<string>;
|
|
45
|
+
private prepareTransactionForSigning;
|
|
46
|
+
private buildSignParams;
|
|
45
47
|
/**
|
|
46
48
|
* Exports the private key for a given account address
|
|
47
49
|
*
|
package/src/svm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/svm/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EAMxB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/svm/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EAMxB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAmBtC,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,EACL,YAAY,GACb,EAAE,wBAAwB;IAY3B;;;;;OAKG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,eAAe,GAChB,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,UAAU,GAAG,MAAM,CAAC;KACnC,CAAC;IA2EI,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU;;;IAY5D;;;;;;OAMG;IACG,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IA8BK,eAAe,CAAC,EACpB,aAAa,EACb,WAAW,EACX,QAAoB,EACpB,eAAe,EACf,QAAQ,EACR,OAAO,GACR,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE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