@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.
@@ -123,7 +123,8 @@ class TurboBaseFactory {
123
123
  }
124
124
  return new arbundles_1.HexInjectedSolanaSigner(walletAdapter);
125
125
  }
126
- if (token === 'ethereum') {
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
  }
@@ -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) {
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '1.31.0';
20
+ exports.version = '1.31.1-alpha.2';
@@ -120,7 +120,8 @@ export class TurboBaseFactory {
120
120
  }
121
121
  return new HexInjectedSolanaSigner(walletAdapter);
122
122
  }
123
- if (token === 'ethereum') {
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
  }
@@ -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) {
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '1.31.0';
17
+ export const version = '1.31.1-alpha.2';
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAwBA,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,CAoCd;AA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AAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CActB;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,CAEhD"}
@@ -13,5 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "1.31.0-alpha.3";
16
+ export declare const version = "1.31.1-alpha.1";
17
17
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.31.0",
3
+ "version": "1.31.1-alpha.2",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",