@ar.io/sdk 2.4.0-alpha.13 → 2.4.0-alpha.15

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.
@@ -43,20 +43,21 @@ class AOProcess {
43
43
  process: this.processId,
44
44
  tags,
45
45
  });
46
+ this.logger.debug(`Read interaction result`, {
47
+ result,
48
+ });
46
49
  if (result.Messages === undefined || result.Messages.length === 0) {
47
50
  this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
48
51
  throw new Error(`Process ${this.processId} does not support provided action.`);
49
52
  }
50
53
  const tagsOutput = result.Messages[0].Tags;
54
+ const messageData = result.Messages[0].Data;
51
55
  const error = tagsOutput.find((tag) => tag.name === 'Error');
52
56
  if (error) {
53
- throw new Error(`${error.Value}: ${result.Messages[0].Data}`);
57
+ throw new Error(`${error.value}${messageData ? `: ${messageData}` : ''}`);
54
58
  }
55
- this.logger.debug(`Read interaction result`, {
56
- result: result.Messages[0].Data,
57
- });
58
59
  // return empty object if no data is returned
59
- if (result.Messages[0].Data === undefined) {
60
+ if (messageData === undefined) {
60
61
  return {};
61
62
  }
62
63
  const response = (0, json_js_1.safeDecode)(result.Messages[0].Data);
@@ -140,6 +140,27 @@ class IOReadable {
140
140
  tags: (0, arweave_js_1.pruneTags)(allTags),
141
141
  });
142
142
  }
143
+ async getVault({ address, vaultId, }) {
144
+ return this.process.read({
145
+ tags: [
146
+ { name: 'Action', value: 'Vault' },
147
+ { name: 'Address', value: address },
148
+ { name: 'Vault-Id', value: vaultId },
149
+ ],
150
+ });
151
+ }
152
+ async getVaults(params) {
153
+ const allTags = [
154
+ { name: 'Action', value: 'Paginated-Vaults' },
155
+ { name: 'Cursor', value: params?.cursor?.toString() },
156
+ { name: 'Limit', value: params?.limit?.toString() },
157
+ { name: 'Sort-By', value: params?.sortBy },
158
+ { name: 'Sort-Order', value: params?.sortOrder },
159
+ ];
160
+ return this.process.read({
161
+ tags: (0, arweave_js_1.pruneTags)(allTags),
162
+ });
163
+ }
143
164
  async getGateway({ address, }) {
144
165
  return this.process.read({
145
166
  tags: [
@@ -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 = '2.4.0-alpha.13';
20
+ exports.version = '2.4.0-alpha.15';
@@ -40,20 +40,21 @@ export class AOProcess {
40
40
  process: this.processId,
41
41
  tags,
42
42
  });
43
+ this.logger.debug(`Read interaction result`, {
44
+ result,
45
+ });
43
46
  if (result.Messages === undefined || result.Messages.length === 0) {
44
47
  this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
45
48
  throw new Error(`Process ${this.processId} does not support provided action.`);
46
49
  }
47
50
  const tagsOutput = result.Messages[0].Tags;
51
+ const messageData = result.Messages[0].Data;
48
52
  const error = tagsOutput.find((tag) => tag.name === 'Error');
49
53
  if (error) {
50
- throw new Error(`${error.Value}: ${result.Messages[0].Data}`);
54
+ throw new Error(`${error.value}${messageData ? `: ${messageData}` : ''}`);
51
55
  }
52
- this.logger.debug(`Read interaction result`, {
53
- result: result.Messages[0].Data,
54
- });
55
56
  // return empty object if no data is returned
56
- if (result.Messages[0].Data === undefined) {
57
+ if (messageData === undefined) {
57
58
  return {};
58
59
  }
59
60
  const response = safeDecode(result.Messages[0].Data);
@@ -136,6 +136,27 @@ export class IOReadable {
136
136
  tags: pruneTags(allTags),
137
137
  });
138
138
  }
139
+ async getVault({ address, vaultId, }) {
140
+ return this.process.read({
141
+ tags: [
142
+ { name: 'Action', value: 'Vault' },
143
+ { name: 'Address', value: address },
144
+ { name: 'Vault-Id', value: vaultId },
145
+ ],
146
+ });
147
+ }
148
+ async getVaults(params) {
149
+ const allTags = [
150
+ { name: 'Action', value: 'Paginated-Vaults' },
151
+ { name: 'Cursor', value: params?.cursor?.toString() },
152
+ { name: 'Limit', value: params?.limit?.toString() },
153
+ { name: 'Sort-By', value: params?.sortBy },
154
+ { name: 'Sort-Order', value: params?.sortOrder },
155
+ ];
156
+ return this.process.read({
157
+ tags: pruneTags(allTags),
158
+ });
159
+ }
139
160
  async getGateway({ address, }) {
140
161
  return this.process.read({
141
162
  tags: [
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '2.4.0-alpha.13';
17
+ export const version = '2.4.0-alpha.15';
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import Arweave from 'arweave';
17
17
  import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
18
- import { AoArNSNameData, AoAuctionPriceData, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegate, AoIORead, AoIOWrite, AoRegistrationFees, EpochInput } from '../types/io.js';
18
+ import { AoArNSNameData, AoAuctionPriceData, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoIORead, AoIOWrite, AoRegistrationFees, AoVaultData, AoWalletVault, EpochInput } from '../types/io.js';
19
19
  import { mIOToken } from '../types/token.js';
20
20
  import { AOProcess } from './contracts/ao-process.js';
21
21
  export declare class IO {
@@ -64,12 +64,18 @@ export declare class IOReadable implements AoIORead {
64
64
  address: WalletAddress;
65
65
  }): Promise<number>;
66
66
  getBalances(params?: PaginationParams<AoBalanceWithAddress>): Promise<PaginationResult<AoBalanceWithAddress>>;
67
+ getVault({ address, vaultId, }: {
68
+ address: WalletAddress;
69
+ vaultId: string;
70
+ }): Promise<AoVaultData>;
71
+ getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
67
72
  getGateway({ address, }: {
68
73
  address: WalletAddress;
69
74
  }): Promise<AoGateway | undefined>;
70
75
  getGatewayDelegates({ address, ...pageParams }: {
71
- address: WalletAddress;
72
- } & PaginationParams<AoGatewayDelegate>): Promise<PaginationResult<AoGatewayDelegate>>;
76
+ [x: string]: any;
77
+ address: any;
78
+ }): Promise<PaginationResult<AoGatewayDelegateWithAddress>>;
73
79
  getGatewayDelegateAllowList({ address, ...pageParams }: {
74
80
  address: WalletAddress;
75
81
  } & PaginationParams<WalletAddress>): Promise<PaginationResult<WalletAddress>>;
@@ -65,7 +65,7 @@ export type AoEpochObservationData = {
65
65
  };
66
66
  export type AoVaultData = {
67
67
  balance: number;
68
- startTimestamp: number;
68
+ startTimestamp: Timestamp;
69
69
  endTimestamp: Timestamp;
70
70
  };
71
71
  export type AoEpochDistributionRewards = {
@@ -144,6 +144,10 @@ export type AoGatewayServices = {
144
144
  } | undefined;
145
145
  export type AoGatewayDelegates = Record<WalletAddress, AoGatewayDelegate>;
146
146
  export type AoGatewayDelegateAllowList = WalletAddress[];
147
+ export type AoWalletVault = AoVaultData & {
148
+ address: WalletAddress;
149
+ vaultId: string;
150
+ };
147
151
  export type AoGateway = {
148
152
  settings: AoGatewaySettings;
149
153
  stats: AoGatewayStats;
@@ -188,6 +192,9 @@ export type AoGatewayDelegate = {
188
192
  startTimestamp: Timestamp;
189
193
  vaults: Record<WalletAddress, AoVaultData>;
190
194
  };
195
+ export type AoGatewayDelegateWithAddress = AoGatewayDelegate & {
196
+ address: WalletAddress;
197
+ };
191
198
  export type AoGatewaySettings = {
192
199
  allowDelegatedStaking: boolean | 'allowlist';
193
200
  delegateRewardShareRatio: number;
@@ -242,12 +249,10 @@ export interface AoIORead {
242
249
  getGateway({ address, }: {
243
250
  address: WalletAddress;
244
251
  }): Promise<AoGateway | undefined>;
245
- getGatewayDelegates(params: {
246
- address: WalletAddress;
247
- } & PaginationParams<AoGatewayDelegate>): Promise<PaginationResult<AoGatewayDelegate>>;
248
- getGatewayDelegateAllowList(params?: PaginationParams<WalletAddress> & {
252
+ getGatewayDelegates({ address, ...pageParams }: {
249
253
  address: WalletAddress;
250
- }): Promise<PaginationResult<WalletAddress>>;
254
+ } & PaginationParams<AoGatewayDelegateWithAddress>): Promise<PaginationResult<AoGatewayDelegateWithAddress>>;
255
+ getGatewayDelegateAllowList(params?: PaginationParams<WalletAddress>): Promise<PaginationResult<WalletAddress>>;
251
256
  getGateways(params?: PaginationParams<AoGatewayWithAddress>): Promise<PaginationResult<AoGatewayWithAddress>>;
252
257
  getBalance(params: {
253
258
  address: WalletAddress;
@@ -287,6 +292,11 @@ export interface AoIORead {
287
292
  }): Promise<number>;
288
293
  getRegistrationFees(): Promise<AoRegistrationFees>;
289
294
  getDemandFactor(): Promise<number>;
295
+ getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
296
+ getVault({ address, vaultId, }: {
297
+ address: WalletAddress;
298
+ vaultId: string;
299
+ }): Promise<AoVaultData>;
290
300
  }
291
301
  export interface AoIOWrite extends AoIORead {
292
302
  transfer({ target, qty, }: {
@@ -13,4 +13,4 @@
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 = "2.4.0-alpha.12";
16
+ export declare const version = "2.4.0-alpha.14";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.4.0-alpha.13",
3
+ "version": "2.4.0-alpha.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"