@ar.io/sdk 3.3.1 → 3.4.0-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/README.md +109 -2
- package/bundles/web.bundle.min.js +2 -2
- package/lib/cjs/cli/cli.js +13 -1
- package/lib/cjs/cli/commands/transfer.js +59 -3
- package/lib/cjs/cli/options.js +21 -1
- package/lib/cjs/cli/utils.js +5 -1
- package/lib/cjs/common/ant.js +97 -2
- package/lib/cjs/common/io.js +26 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +15 -3
- package/lib/esm/cli/commands/transfer.js +56 -2
- package/lib/esm/cli/options.js +20 -0
- package/lib/esm/cli/utils.js +3 -0
- package/lib/esm/common/ant.js +97 -2
- package/lib/esm/common/io.js +26 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/transfer.d.ts +5 -2
- package/lib/types/cli/options.d.ts +17 -0
- package/lib/types/cli/utils.d.ts +1 -0
- package/lib/types/common/ant.d.ts +88 -2
- package/lib/types/common/io.d.ts +3 -1
- package/lib/types/types/ant.d.ts +12 -0
- package/lib/types/types/io.d.ts +12 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
33
33
|
- [Vaults](#vaults)
|
|
34
34
|
- [`getVault({ address, vaultId })`](#getvault-address-vaultid-)
|
|
35
35
|
- [`getVaults({ cursor, limit, sortBy, sortOrder })`](#getvaults-cursor-limit-sortby-sortorder-)
|
|
36
|
+
- [`vaultedTransfer({ recipient, quantity, lockLengthMs, revokable })`](#vaultedtransfer-recipient-quantity-locklengthms-revokable-)
|
|
37
|
+
- [`revokeVault({ recipient, vaultId })`](#revokevault-recipient-vaultid-)
|
|
36
38
|
- [Gateways](#gateways)
|
|
37
39
|
- [`getGateway({ address })`](#getgateway-address-)
|
|
38
40
|
- [`getGateways({ cursor, limit, sortBy, sortOrder })`](#getgateways-cursor-limit-sortby-sortorder-)
|
|
@@ -89,6 +91,9 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
89
91
|
- [`transfer({ target })`](#transfer-target-)
|
|
90
92
|
- [`setController({ controller })`](#setcontroller-controller-)
|
|
91
93
|
- [`removeController({ controller })`](#removecontroller-controller-)
|
|
94
|
+
- [`setBaseNameRecord({ transactionId, ttlSeconds })`](#setbasenamerecord-transactionid-ttlseconds-)
|
|
95
|
+
- [`setUndernameRecord({ undername, transactionId, ttlSeconds })`](#setundernamerecord-undername-transactionid-ttlseconds-)
|
|
96
|
+
- [`removeUndernameRecord({ undername })`](#removeundernamerecord-undername-)
|
|
92
97
|
- [`setRecord({ undername, transactionId, ttlSeconds })`](#setrecord-undername-transactionid-ttlseconds-)
|
|
93
98
|
- [`removeRecord({ undername })`](#removerecord-undername-)
|
|
94
99
|
- [`setName({ name })`](#setname-name-)
|
|
@@ -511,6 +516,40 @@ const vaults = await ario.getVaults({
|
|
|
511
516
|
|
|
512
517
|
</details>
|
|
513
518
|
|
|
519
|
+
#### `vaultedTransfer({ recipient, quantity, lockLengthMs, revokable })`
|
|
520
|
+
|
|
521
|
+
Transfers `mARIO` to the designated `recipient` address and locks the balance for the specified `lockLengthMs` milliseconds. The `revokable` flag determines if the vaulted transfer can be revoked by the sender.
|
|
522
|
+
|
|
523
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
524
|
+
|
|
525
|
+
```typescript
|
|
526
|
+
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
527
|
+
const { id: txId } = await ario.vaultedTransfer(
|
|
528
|
+
{
|
|
529
|
+
recipient: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
530
|
+
quantity: new ARIOToken(1000).toMARIO(),
|
|
531
|
+
lockLengthMs: 1000 * 60 * 60 * 24 * 365, // 1 year
|
|
532
|
+
revokable: true,
|
|
533
|
+
},
|
|
534
|
+
// optional additional tags
|
|
535
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
536
|
+
);
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
#### `revokeVault({ recipient, vaultId })`
|
|
540
|
+
|
|
541
|
+
Revokes a vaulted transfer by the recipient address and vault ID. Only the sender of the vaulted transfer can revoke it.
|
|
542
|
+
|
|
543
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
547
|
+
const { id: txId } = await ario.revokeVault({
|
|
548
|
+
recipient: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
549
|
+
vaultId: 'IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs',
|
|
550
|
+
});
|
|
551
|
+
```
|
|
552
|
+
|
|
514
553
|
### Gateways
|
|
515
554
|
|
|
516
555
|
#### `getGateway({ address })`
|
|
@@ -2024,9 +2063,70 @@ const { id: txId } = await ant.removeController(
|
|
|
2024
2063
|
);
|
|
2025
2064
|
```
|
|
2026
2065
|
|
|
2066
|
+
#### `setBaseNameRecord({ transactionId, ttlSeconds })`
|
|
2067
|
+
|
|
2068
|
+
Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io)
|
|
2069
|
+
|
|
2070
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2071
|
+
|
|
2072
|
+
```typescript
|
|
2073
|
+
// get the ant for the base name
|
|
2074
|
+
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
|
|
2075
|
+
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2076
|
+
const { id: txId } = await ant.setBaseNameRecord({
|
|
2077
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
2078
|
+
ttlSeconds: 3600,
|
|
2079
|
+
});
|
|
2080
|
+
|
|
2081
|
+
// ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
|
|
2082
|
+
```
|
|
2083
|
+
|
|
2084
|
+
#### `setUndernameRecord({ undername, transactionId, ttlSeconds })`
|
|
2085
|
+
|
|
2086
|
+
Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io)
|
|
2087
|
+
|
|
2088
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2089
|
+
|
|
2090
|
+
> Records, or `undernames` are configured with the `transactionId` - the arweave transaction id the record resolves - and `ttlSeconds`, the Time To Live in the cache of client applications.
|
|
2091
|
+
|
|
2092
|
+
```typescript
|
|
2093
|
+
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
|
|
2094
|
+
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2095
|
+
const { id: txId } = await ant.setUndernameRecord(
|
|
2096
|
+
{
|
|
2097
|
+
undername: 'dapp',
|
|
2098
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
2099
|
+
ttlSeconds: 900,
|
|
2100
|
+
},
|
|
2101
|
+
// optional additional tags
|
|
2102
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
2103
|
+
);
|
|
2104
|
+
|
|
2105
|
+
// dapp_ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
|
|
2106
|
+
```
|
|
2107
|
+
|
|
2108
|
+
#### `removeUndernameRecord({ undername })`
|
|
2109
|
+
|
|
2110
|
+
Removes an undername record from the ANT process.
|
|
2111
|
+
|
|
2112
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2113
|
+
|
|
2114
|
+
```typescript
|
|
2115
|
+
const { id: txId } = await ant.removeUndernameRecord(
|
|
2116
|
+
{ undername: 'dapp' },
|
|
2117
|
+
// optional additional tags
|
|
2118
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
2119
|
+
);
|
|
2120
|
+
|
|
2121
|
+
// dapp_ardrive.ar.io will no longer resolve to the provided transaction id
|
|
2122
|
+
```
|
|
2123
|
+
|
|
2027
2124
|
#### `setRecord({ undername, transactionId, ttlSeconds })`
|
|
2028
2125
|
|
|
2029
|
-
|
|
2126
|
+
> [!WARNING]
|
|
2127
|
+
> Deprecated: Use `setBaseNameRecord` or `setUndernameRecord` instead.
|
|
2128
|
+
|
|
2129
|
+
Adds or updates a record for the ANT process. The `undername` parameter is used to specify the record name. Use `@` for the base name record.
|
|
2030
2130
|
|
|
2031
2131
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2032
2132
|
|
|
@@ -2046,16 +2146,23 @@ const { id: txId } = await ant.setRecord(
|
|
|
2046
2146
|
|
|
2047
2147
|
#### `removeRecord({ undername })`
|
|
2048
2148
|
|
|
2149
|
+
> [!WARNING]
|
|
2150
|
+
> Deprecated: Use `removeUndernameRecord` instead.
|
|
2151
|
+
|
|
2049
2152
|
Removes a record from the ANT process.
|
|
2050
2153
|
|
|
2051
2154
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2052
2155
|
|
|
2053
2156
|
```typescript
|
|
2157
|
+
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
|
|
2158
|
+
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2054
2159
|
const { id: txId } = await ant.removeRecord(
|
|
2055
|
-
{ undername: '
|
|
2160
|
+
{ undername: 'dapp' },
|
|
2056
2161
|
// optional additional tags
|
|
2057
2162
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
2058
2163
|
);
|
|
2164
|
+
|
|
2165
|
+
// dapp_ardrive.ar.io will no longer resolve to the provided transaction id
|
|
2059
2166
|
```
|
|
2060
2167
|
|
|
2061
2168
|
#### `setName({ name })`
|