@dynamic-labs-wallet/svm 0.0.124 → 0.0.126
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 +22 -5
- package/index.esm.js +22 -5
- package/package.json +2 -2
- package/src/svm/client.d.ts +2 -1
- package/src/svm/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var browser = require('@dynamic-labs-wallet/browser');
|
|
4
|
-
var bs58 = require('bs58');
|
|
5
4
|
var web3_js = require('@solana/web3.js');
|
|
5
|
+
var bs58 = require('bs58');
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
8
8
|
_extends = Object.assign || function assign(target) {
|
|
@@ -80,7 +80,7 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
async deriveAccountAddress(rawPublicKey) {
|
|
83
|
-
const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
|
|
83
|
+
const pubKeyBytes = typeof rawPublicKey === 'string' ? new Uint8Array(Buffer.from(rawPublicKey, 'hex')) : rawPublicKey;
|
|
84
84
|
const accountAddress = bs58.encode(pubKeyBytes);
|
|
85
85
|
return {
|
|
86
86
|
accountAddress
|
|
@@ -118,22 +118,39 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
118
118
|
throw new Error(browser.ERROR_SIGN_MESSAGE);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken }) {
|
|
121
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, chainId }) {
|
|
122
122
|
await this.verifyPassword({
|
|
123
123
|
accountAddress: senderAddress,
|
|
124
124
|
password,
|
|
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);
|
|
128
133
|
try {
|
|
129
|
-
const
|
|
134
|
+
const signParams = {
|
|
130
135
|
message: transaction,
|
|
131
136
|
accountAddress: senderAddress,
|
|
132
137
|
chainName: this.chainName,
|
|
133
138
|
password,
|
|
134
139
|
signedSessionId,
|
|
135
140
|
mfaToken
|
|
136
|
-
}
|
|
141
|
+
};
|
|
142
|
+
if (chainId !== undefined) {
|
|
143
|
+
signParams.context = {
|
|
144
|
+
svmTransaction: {
|
|
145
|
+
chainId,
|
|
146
|
+
method: 'signAndSendTransaction',
|
|
147
|
+
serializedTransactions: [
|
|
148
|
+
base58SerializedTransaction
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const signatureEd25519 = await this.sign(signParams);
|
|
137
154
|
if (!signatureEd25519) {
|
|
138
155
|
throw new Error('Signature is undefined');
|
|
139
156
|
}
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicWalletClient, getClientKeyShareBackupInfo, ERROR_KEYGEN_FAILED, ERROR_CREATE_WALLET_ACCOUNT, WalletOperation, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, ERROR_IMPORT_PRIVATE_KEY } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { VersionedMessage, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
2
3
|
import bs58 from 'bs58';
|
|
3
|
-
import { Keypair } from '@solana/web3.js';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
6
6
|
_extends = Object.assign || function assign(target) {
|
|
@@ -78,7 +78,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
async deriveAccountAddress(rawPublicKey) {
|
|
81
|
-
const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
|
|
81
|
+
const pubKeyBytes = typeof rawPublicKey === 'string' ? new Uint8Array(Buffer.from(rawPublicKey, 'hex')) : rawPublicKey;
|
|
82
82
|
const accountAddress = bs58.encode(pubKeyBytes);
|
|
83
83
|
return {
|
|
84
84
|
accountAddress
|
|
@@ -116,22 +116,39 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
116
116
|
throw new Error(ERROR_SIGN_MESSAGE);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken }) {
|
|
119
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, chainId }) {
|
|
120
120
|
await this.verifyPassword({
|
|
121
121
|
accountAddress: senderAddress,
|
|
122
122
|
password,
|
|
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);
|
|
126
131
|
try {
|
|
127
|
-
const
|
|
132
|
+
const signParams = {
|
|
128
133
|
message: transaction,
|
|
129
134
|
accountAddress: senderAddress,
|
|
130
135
|
chainName: this.chainName,
|
|
131
136
|
password,
|
|
132
137
|
signedSessionId,
|
|
133
138
|
mfaToken
|
|
134
|
-
}
|
|
139
|
+
};
|
|
140
|
+
if (chainId !== undefined) {
|
|
141
|
+
signParams.context = {
|
|
142
|
+
svmTransaction: {
|
|
143
|
+
chainId,
|
|
144
|
+
method: 'signAndSendTransaction',
|
|
145
|
+
serializedTransactions: [
|
|
146
|
+
base58SerializedTransaction
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const signatureEd25519 = await this.sign(signParams);
|
|
135
152
|
if (!signatureEd25519) {
|
|
136
153
|
throw new Error('Signature is undefined');
|
|
137
154
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/svm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.126",
|
|
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.126",
|
|
8
8
|
"@solana/web3.js": "^1.98.2",
|
|
9
9
|
"bs58": "^6.0.0"
|
|
10
10
|
},
|
package/src/svm/client.d.ts
CHANGED
|
@@ -34,12 +34,13 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
34
34
|
signedSessionId: string;
|
|
35
35
|
mfaToken?: string;
|
|
36
36
|
}): Promise<string>;
|
|
37
|
-
signTransaction({ senderAddress, transaction, password, signedSessionId, mfaToken, }: {
|
|
37
|
+
signTransaction({ senderAddress, transaction, password, signedSessionId, mfaToken, chainId, }: {
|
|
38
38
|
senderAddress: string;
|
|
39
39
|
transaction: string;
|
|
40
40
|
password?: string;
|
|
41
41
|
signedSessionId: string;
|
|
42
42
|
mfaToken?: string;
|
|
43
|
+
chainId?: string;
|
|
43
44
|
}): Promise<string>;
|
|
44
45
|
/**
|
|
45
46
|
* Exports the private key for a given account address
|
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,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/svm/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EAMxB,mBAAmB,EAEnB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAQtC,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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