@ardrive/turbo-sdk 1.31.0 → 1.31.1-alpha.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/bundles/web.bundle.min.js +34431 -34421
- package/lib/cjs/common/factory.js +2 -1
- package/lib/cjs/utils/common.js +13 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/factory.js +2 -1
- package/lib/esm/utils/common.js +14 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/utils/common.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -123,7 +123,8 @@ class TurboBaseFactory {
|
|
|
123
123
|
}
|
|
124
124
|
return new arbundles_1.HexInjectedSolanaSigner(walletAdapter);
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
const ethTokens = new Set(['ethereum', 'base-eth']);
|
|
127
|
+
if (ethTokens.has(token)) {
|
|
127
128
|
if (!(0, types_js_1.isEthereumWalletAdapter)(walletAdapter)) {
|
|
128
129
|
throw new Error('Unsupported wallet adapter -- must implement getSigner');
|
|
129
130
|
}
|
package/lib/cjs/utils/common.js
CHANGED
|
@@ -26,6 +26,9 @@ const amino_1 = require("@cosmjs/amino");
|
|
|
26
26
|
const crypto_1 = require("@cosmjs/crypto");
|
|
27
27
|
const encoding_1 = require("@cosmjs/encoding");
|
|
28
28
|
const arbundles_1 = require("@dha-team/arbundles");
|
|
29
|
+
const bytes_1 = require("@ethersproject/bytes");
|
|
30
|
+
const signing_key_1 = require("@ethersproject/signing-key");
|
|
31
|
+
const ethers_1 = require("ethers");
|
|
29
32
|
const types_js_1 = require("../types.js");
|
|
30
33
|
function sleep(ms) {
|
|
31
34
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -67,6 +70,16 @@ exports.defaultProdAoConfigs = {
|
|
|
67
70
|
};
|
|
68
71
|
function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
|
|
69
72
|
if (clientProvidedSigner !== undefined) {
|
|
73
|
+
if (clientProvidedSigner instanceof arbundles_1.InjectedEthereumSigner) {
|
|
74
|
+
// Override the setPublicKey method to resolve a generic string to sign
|
|
75
|
+
clientProvidedSigner.setPublicKey = async () => {
|
|
76
|
+
const message = 'sign this message to connect to your account';
|
|
77
|
+
const signedMsg = await clientProvidedSigner['signer'].signMessage(message);
|
|
78
|
+
const hash = (0, ethers_1.hashMessage)(message);
|
|
79
|
+
const recoveredKey = (0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(hash), signedMsg);
|
|
80
|
+
clientProvidedSigner.publicKey = Buffer.from((0, bytes_1.arrayify)(recoveredKey));
|
|
81
|
+
};
|
|
82
|
+
}
|
|
70
83
|
return clientProvidedSigner;
|
|
71
84
|
}
|
|
72
85
|
if (clientProvidedPrivateKey === undefined) {
|
package/lib/cjs/version.js
CHANGED
|
@@ -120,7 +120,8 @@ export class TurboBaseFactory {
|
|
|
120
120
|
}
|
|
121
121
|
return new HexInjectedSolanaSigner(walletAdapter);
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
const ethTokens = new Set(['ethereum', 'base-eth']);
|
|
124
|
+
if (ethTokens.has(token)) {
|
|
124
125
|
if (!isEthereumWalletAdapter(walletAdapter)) {
|
|
125
126
|
throw new Error('Unsupported wallet adapter -- must implement getSigner');
|
|
126
127
|
}
|
package/lib/esm/utils/common.js
CHANGED
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
import { Secp256k1HdWallet, makeCosmoshubPath } from '@cosmjs/amino';
|
|
17
17
|
import { Slip10, Slip10Curve } from '@cosmjs/crypto';
|
|
18
18
|
import { toHex } from '@cosmjs/encoding';
|
|
19
|
-
import { ArweaveSigner, EthereumSigner, HexSolanaSigner, } from '@dha-team/arbundles';
|
|
19
|
+
import { ArweaveSigner, EthereumSigner, HexSolanaSigner, InjectedEthereumSigner, } from '@dha-team/arbundles';
|
|
20
|
+
import { arrayify } from '@ethersproject/bytes';
|
|
21
|
+
import { recoverPublicKey } from '@ethersproject/signing-key';
|
|
22
|
+
import { hashMessage } from 'ethers';
|
|
20
23
|
import { isEthPrivateKey, isJWK, isKyvePrivateKey, } from '../types.js';
|
|
21
24
|
export function sleep(ms) {
|
|
22
25
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -58,6 +61,16 @@ export const defaultProdAoConfigs = {
|
|
|
58
61
|
};
|
|
59
62
|
export function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
|
|
60
63
|
if (clientProvidedSigner !== undefined) {
|
|
64
|
+
if (clientProvidedSigner instanceof InjectedEthereumSigner) {
|
|
65
|
+
// Override the setPublicKey method to resolve a generic string to sign
|
|
66
|
+
clientProvidedSigner.setPublicKey = async () => {
|
|
67
|
+
const message = 'sign this message to connect to your account';
|
|
68
|
+
const signedMsg = await clientProvidedSigner['signer'].signMessage(message);
|
|
69
|
+
const hash = hashMessage(message);
|
|
70
|
+
const recoveredKey = recoverPublicKey(arrayify(hash), signedMsg);
|
|
71
|
+
clientProvidedSigner.publicKey = Buffer.from(arrayify(recoveredKey));
|
|
72
|
+
};
|
|
73
|
+
}
|
|
61
74
|
return clientProvidedSigner;
|
|
62
75
|
}
|
|
63
76
|
if (clientProvidedPrivateKey === undefined) {
|
package/lib/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EAIZ,MAAM,aAAa,CAAC;AAErB,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED,wBAAgB,KAAK,YAEpB;AAED,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAS1D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE;IAClC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAM5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAS5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE;IACjC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAM5C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,wBAAwB,EACpC,KAAiB,GAClB,EAAE;IACD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,WAAW,CA+Cd;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAGxE;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CActB;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,CAEhD"}
|
package/lib/types/version.d.ts
CHANGED