@ar.io/sdk 2.4.0-alpha.14 → 2.4.0-alpha.16

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.14';
20
+ exports.version = '2.4.0-alpha.16';
@@ -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.14';
17
+ export const version = '2.4.0-alpha.16';
@@ -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, AoGatewayDelegateWithAddress, 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,6 +64,11 @@ 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>;
@@ -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,8 +144,13 @@ 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;
153
+ delegates: AoGatewayDelegates;
149
154
  stats: AoGatewayStats;
150
155
  totalDelegatedStake: number;
151
156
  vaults: Record<WalletAddress, AoVaultData>;
@@ -288,6 +293,11 @@ export interface AoIORead {
288
293
  }): Promise<number>;
289
294
  getRegistrationFees(): Promise<AoRegistrationFees>;
290
295
  getDemandFactor(): Promise<number>;
296
+ getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
297
+ getVault({ address, vaultId, }: {
298
+ address: WalletAddress;
299
+ vaultId: string;
300
+ }): Promise<AoVaultData>;
291
301
  }
292
302
  export interface AoIOWrite extends AoIORead {
293
303
  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.13";
16
+ export declare const version = "2.4.0-alpha.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.4.0-alpha.14",
3
+ "version": "2.4.0-alpha.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"