@ar.io/sdk 2.1.0-alpha.11 → 2.1.0-alpha.13

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.
@@ -31,5 +31,5 @@ exports.IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
31
31
  exports.ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
32
32
  exports.MIO_PER_IO = 1_000_000;
33
33
  exports.AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
34
- exports.ANT_LUA_ID = 'Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI';
34
+ exports.ANT_LUA_ID = 'BVZZ0_ME8uq3zChN6bA6WsPmFhVpGDJ7Rb7l4qoGIDM';
35
35
  exports.DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAoSigner = exports.evolveANT = exports.spawnANT = void 0;
3
+ exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
6
  *
@@ -19,6 +19,7 @@ exports.createAoSigner = exports.evolveANT = exports.spawnANT = void 0;
19
19
  */
20
20
  const aoconnect_1 = require("@permaweb/aoconnect");
21
21
  const arbundles_1 = require("arbundles");
22
+ const zod_1 = require("zod");
22
23
  const arweave_js_1 = require("../common/arweave.js");
23
24
  const index_js_1 = require("../common/index.js");
24
25
  const constants_js_1 = require("../constants.js");
@@ -101,7 +102,36 @@ async function evolveANT({ signer, processId, luaCodeTxId = constants_js_1.ANT_L
101
102
  return id;
102
103
  }
103
104
  exports.evolveANT = evolveANT;
105
+ function isAoSigner(value) {
106
+ const TagSchema = zod_1.z.object({
107
+ name: zod_1.z.string(),
108
+ value: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]),
109
+ });
110
+ const AoSignerSchema = zod_1.z
111
+ .function()
112
+ .args(zod_1.z.object({
113
+ data: zod_1.z.union([zod_1.z.string(), zod_1.z.instanceof(Buffer)]),
114
+ tags: zod_1.z.array(TagSchema).optional(),
115
+ target: zod_1.z.string().optional(),
116
+ anchor: zod_1.z.string().optional(),
117
+ }))
118
+ .returns(zod_1.z.promise(zod_1.z.object({
119
+ id: zod_1.z.string(),
120
+ raw: zod_1.z.instanceof(ArrayBuffer),
121
+ })));
122
+ try {
123
+ AoSignerSchema.parse(value);
124
+ return true;
125
+ }
126
+ catch {
127
+ return false;
128
+ }
129
+ }
130
+ exports.isAoSigner = isAoSigner;
104
131
  function createAoSigner(signer) {
132
+ if (isAoSigner(signer)) {
133
+ return signer;
134
+ }
105
135
  if (!('publicKey' in signer)) {
106
136
  return (0, aoconnect_1.createDataItemSigner)(signer);
107
137
  }
@@ -18,4 +18,4 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.version = void 0;
20
20
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
21
- exports.version = '2.1.0-alpha.11';
21
+ exports.version = '2.1.0-alpha.13';
@@ -28,5 +28,5 @@ export const IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdi
28
28
  export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
29
29
  export const MIO_PER_IO = 1_000_000;
30
30
  export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
31
- export const ANT_LUA_ID = 'Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI';
31
+ export const ANT_LUA_ID = 'BVZZ0_ME8uq3zChN6bA6WsPmFhVpGDJ7Rb7l4qoGIDM';
32
32
  export const DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { connect, createDataItemSigner } from '@permaweb/aoconnect';
18
18
  import { createData } from 'arbundles';
19
+ import { z } from 'zod';
19
20
  import { defaultArweave } from '../common/arweave.js';
20
21
  import { AOProcess } from '../common/index.js';
21
22
  import { ANT_LUA_ID, ANT_REGISTRY_ID, AOS_MODULE_ID, DEFAULT_SCHEDULER_ID, } from '../constants.js';
@@ -96,7 +97,35 @@ export async function evolveANT({ signer, processId, luaCodeTxId = ANT_LUA_ID, a
96
97
  });
97
98
  return id;
98
99
  }
100
+ export function isAoSigner(value) {
101
+ const TagSchema = z.object({
102
+ name: z.string(),
103
+ value: z.union([z.string(), z.number()]),
104
+ });
105
+ const AoSignerSchema = z
106
+ .function()
107
+ .args(z.object({
108
+ data: z.union([z.string(), z.instanceof(Buffer)]),
109
+ tags: z.array(TagSchema).optional(),
110
+ target: z.string().optional(),
111
+ anchor: z.string().optional(),
112
+ }))
113
+ .returns(z.promise(z.object({
114
+ id: z.string(),
115
+ raw: z.instanceof(ArrayBuffer),
116
+ })));
117
+ try {
118
+ AoSignerSchema.parse(value);
119
+ return true;
120
+ }
121
+ catch {
122
+ return false;
123
+ }
124
+ }
99
125
  export function createAoSigner(signer) {
126
+ if (isAoSigner(signer)) {
127
+ return signer;
128
+ }
100
129
  if (!('publicKey' in signer)) {
101
130
  return createDataItemSigner(signer);
102
131
  }
@@ -15,4 +15,4 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
18
- export const version = '2.1.0-alpha.11';
18
+ export const version = '2.1.0-alpha.13';
@@ -17,13 +17,14 @@
17
17
  */
18
18
  import { dryrun, message, monitor, result, results, spawn, unmonitor } from '@permaweb/aoconnect';
19
19
  import { Signer } from 'arbundles';
20
+ import { AoSigner } from './token.js';
20
21
  export type BlockHeight = number;
21
22
  export type SortKey = string;
22
23
  export type Timestamp = number;
23
24
  export type WalletAddress = string;
24
25
  export type TransactionId = string;
25
26
  export type ProcessId = string;
26
- export type ContractSigner = Signer | Window['arweaveWallet'];
27
+ export type ContractSigner = Signer | Window['arweaveWallet'] | AoSigner;
27
28
  export type WithSigner<T = NonNullable<unknown>> = {
28
29
  signer: ContractSigner;
29
30
  } & T;
@@ -26,5 +26,5 @@ export declare const IO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmt
26
26
  export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
27
27
  export declare const MIO_PER_IO = 1000000;
28
28
  export declare const AOS_MODULE_ID = "cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk";
29
- export declare const ANT_LUA_ID = "Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI";
29
+ export declare const ANT_LUA_ID = "BVZZ0_ME8uq3zChN6bA6WsPmFhVpGDJ7Rb7l4qoGIDM";
30
30
  export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
@@ -22,4 +22,5 @@ export declare function evolveANT({ signer, processId, luaCodeTxId, ao, }: {
22
22
  luaCodeTxId?: string;
23
23
  ao?: AoClient;
24
24
  }): Promise<string>;
25
+ export declare function isAoSigner(value: unknown): value is AoSigner;
25
26
  export declare function createAoSigner(signer: ContractSigner): AoSigner;
@@ -14,4 +14,4 @@
14
14
  * You should have received a copy of the GNU Affero General Public License
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
- export declare const version = "2.1.0-alpha.10";
17
+ export declare const version = "2.1.0-alpha.12";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.1.0-alpha.11",
3
+ "version": "2.1.0-alpha.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"
@@ -127,7 +127,8 @@
127
127
  "axios-retry": "^4.3.0",
128
128
  "eventemitter3": "^5.0.1",
129
129
  "plimit-lit": "^3.0.1",
130
- "winston": "^3.13.0"
130
+ "winston": "^3.13.0",
131
+ "zod": "^3.23.8"
131
132
  },
132
133
  "lint-staged": {
133
134
  "**/*.{ts,js,mjs,cjs,md,json}": [