@ar.io/sdk 3.2.0 → 3.3.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/bundles/web.bundle.min.js +89 -69
- package/lib/cjs/cli/cli.js +6 -2
- package/lib/cjs/common/contracts/ao-process.js +1 -1
- package/lib/cjs/common/io.js +56 -21
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/utils/ao.js +22 -22
- package/lib/cjs/utils/arweave.js +51 -16
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +6 -2
- package/lib/esm/common/contracts/ao-process.js +1 -1
- package/lib/esm/common/io.js +57 -22
- package/lib/esm/constants.js +1 -1
- package/lib/esm/utils/ao.js +20 -21
- package/lib/esm/utils/arweave.js +49 -16
- package/lib/esm/version.js +1 -1
- package/lib/types/common/contracts/ao-process.d.ts +1 -1
- package/lib/types/common/io.d.ts +28 -6
- package/lib/types/constants.d.ts +1 -1
- package/lib/types/types/io.d.ts +2 -2
- package/lib/types/utils/ao.d.ts +13 -3
- package/lib/types/utils/arweave.d.ts +31 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { ARWEAVE_TX_REGEX } from '../constants.js';
|
|
1
|
+
import { ARIO_TESTNET_PROCESS_ID, ARWEAVE_TX_REGEX } from '../constants.js';
|
|
2
|
+
import { parseAoEpochData } from './ao.js';
|
|
17
3
|
export const validateArweaveId = (id) => {
|
|
18
4
|
return ARWEAVE_TX_REGEX.test(id);
|
|
19
5
|
};
|
|
@@ -37,3 +23,50 @@ export const paginationParamsToTags = (params) => {
|
|
|
37
23
|
];
|
|
38
24
|
return pruneTags(tags);
|
|
39
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Get the epoch with distribution data for the current epoch
|
|
28
|
+
* @param arweave - The Arweave instance
|
|
29
|
+
* @returns The epoch with distribution data
|
|
30
|
+
*/
|
|
31
|
+
export const getEpochDataFromGql = async ({ arweave, epochIndex, processId = ARIO_TESTNET_PROCESS_ID, }) => {
|
|
32
|
+
// fetch from gql
|
|
33
|
+
const query = epochDistributionNoticeGqlQuery({ epochIndex, processId });
|
|
34
|
+
const response = await arweave.api.post('graphql', query);
|
|
35
|
+
// parse the nodes to get the id
|
|
36
|
+
if (response.data.data.transactions?.edges?.length === 0) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const id = response.data.data.transactions.edges[0].node.id;
|
|
40
|
+
// fetch the transaction from arweave
|
|
41
|
+
const transaction = await arweave.api.get(id);
|
|
42
|
+
const data = transaction.data;
|
|
43
|
+
// assert it is the correct type
|
|
44
|
+
return parseAoEpochData(data);
|
|
45
|
+
};
|
|
46
|
+
export const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = ARIO_TESTNET_PROCESS_ID, }) => {
|
|
47
|
+
// write the query
|
|
48
|
+
const gqlQuery = JSON.stringify({
|
|
49
|
+
query: `
|
|
50
|
+
query {
|
|
51
|
+
transactions(
|
|
52
|
+
tags: [
|
|
53
|
+
{ name: "From-Process", values: ["${processId}"] }
|
|
54
|
+
{ name: "Action", values: ["Epoch-Distribution-Notice"] }
|
|
55
|
+
{ name: "Epoch-Index", values: ["${epochIndex}"] }
|
|
56
|
+
{ name: "Data-Protocol", values: ["ao"] }
|
|
57
|
+
],
|
|
58
|
+
owners: ["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"],
|
|
59
|
+
first: 1,
|
|
60
|
+
sort: HEIGHT_DESC
|
|
61
|
+
) {
|
|
62
|
+
edges {
|
|
63
|
+
node {
|
|
64
|
+
id
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
});
|
|
71
|
+
return gqlQuery;
|
|
72
|
+
};
|
package/lib/esm/version.js
CHANGED
|
@@ -2,8 +2,8 @@ import { AOContract, AoClient, AoSigner } from '../../types/index.js';
|
|
|
2
2
|
import { ILogger } from '../logger.js';
|
|
3
3
|
export declare class AOProcess implements AOContract {
|
|
4
4
|
private logger;
|
|
5
|
-
private processId;
|
|
6
5
|
private ao;
|
|
6
|
+
readonly processId: string;
|
|
7
7
|
constructor({ processId, ao, logger, }: {
|
|
8
8
|
processId: string;
|
|
9
9
|
ao?: AoClient;
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import Arweave from 'arweave';
|
|
1
17
|
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
2
18
|
import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
3
19
|
import { mARIOToken } from '../types/token.js';
|
|
@@ -24,7 +40,10 @@ export declare class ARIO {
|
|
|
24
40
|
export declare class ARIOReadable implements AoARIORead {
|
|
25
41
|
protected process: AOProcess;
|
|
26
42
|
protected epochSettings: AoEpochSettings | undefined;
|
|
27
|
-
|
|
43
|
+
protected arweave: Arweave;
|
|
44
|
+
constructor({ arweave, ...config }: ProcessConfiguration & {
|
|
45
|
+
arweave?: Arweave;
|
|
46
|
+
});
|
|
28
47
|
getInfo(): Promise<{
|
|
29
48
|
Name: string;
|
|
30
49
|
Ticker: string;
|
|
@@ -36,9 +55,10 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
36
55
|
}>;
|
|
37
56
|
getTokenSupply(): Promise<AoTokenSupplyData>;
|
|
38
57
|
private computeEpochIndexForTimestamp;
|
|
58
|
+
private computeCurrentEpochIndex;
|
|
39
59
|
private computeEpochIndex;
|
|
40
60
|
getEpochSettings(): Promise<AoEpochSettings>;
|
|
41
|
-
getEpoch(epoch?: EpochInput): Promise<AoEpochData>;
|
|
61
|
+
getEpoch(epoch?: EpochInput): Promise<AoEpochData | undefined>;
|
|
42
62
|
getArNSRecord({ name, }: {
|
|
43
63
|
name: string;
|
|
44
64
|
}): Promise<AoArNSNameData | undefined>;
|
|
@@ -68,8 +88,8 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
68
88
|
getCurrentEpoch(): Promise<AoEpochData>;
|
|
69
89
|
getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
|
|
70
90
|
getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
|
|
71
|
-
getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
|
|
72
|
-
getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
|
|
91
|
+
getObservations(epoch?: EpochInput): Promise<AoEpochObservationData | undefined>;
|
|
92
|
+
getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData | undefined>;
|
|
73
93
|
getTokenCost(params: {
|
|
74
94
|
intent: 'Buy-Record';
|
|
75
95
|
type: 'permabuy' | 'lease';
|
|
@@ -134,11 +154,13 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
134
154
|
export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
135
155
|
protected process: AOProcess;
|
|
136
156
|
private signer;
|
|
137
|
-
constructor({ signer, ...config }: WithSigner<{
|
|
157
|
+
constructor({ signer, arweave, ...config }: WithSigner<{
|
|
138
158
|
process?: AOProcess;
|
|
139
159
|
} | {
|
|
140
160
|
processId?: string;
|
|
141
|
-
}>
|
|
161
|
+
}> & {
|
|
162
|
+
arweave?: Arweave;
|
|
163
|
+
});
|
|
142
164
|
transfer({ target, qty, }: {
|
|
143
165
|
target: string;
|
|
144
166
|
qty: number | mARIOToken;
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -24,6 +24,6 @@ export declare const arioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6
|
|
|
24
24
|
export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
|
|
25
25
|
export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
|
|
26
26
|
export declare const MARIO_PER_ARIO = 1000000;
|
|
27
|
-
export declare const AOS_MODULE_ID = "
|
|
27
|
+
export declare const AOS_MODULE_ID = "tyojTpJ9fIva_7BjTA9ruGM4uk2vyTfhVUulnbVxR8I";
|
|
28
28
|
export declare const ANT_LUA_ID = "16_FyX-V2QU0RPSh1GIaEETSaUjNb0oVjCFpVbAfQq4";
|
|
29
29
|
export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -389,8 +389,8 @@ export interface AoARIORead {
|
|
|
389
389
|
getCurrentEpoch(): Promise<AoEpochData>;
|
|
390
390
|
getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
|
|
391
391
|
getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
|
|
392
|
-
getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
|
|
393
|
-
getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
|
|
392
|
+
getObservations(epoch?: EpochInput): Promise<AoEpochObservationData | undefined>;
|
|
393
|
+
getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData | undefined>;
|
|
394
394
|
getTokenCost({ intent, type, years, name, quantity, }: AoTokenCostParams): Promise<number>;
|
|
395
395
|
getCostDetails({ intent, type, years, name, quantity, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
|
|
396
396
|
getRegistrationFees(): Promise<AoRegistrationFees>;
|
package/lib/types/utils/ao.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
2
|
import { Logger } from '../common/index.js';
|
|
3
3
|
import { AoANTRecord } from '../types/ant.js';
|
|
4
|
-
import { AoClient, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
|
|
4
|
+
import { AoClient, AoEpochData, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
|
|
5
5
|
export type SpawnANTState = {
|
|
6
6
|
owner: WalletAddress;
|
|
7
7
|
controllers: WalletAddress[];
|
|
@@ -15,16 +15,22 @@ export type SpawnANTState = {
|
|
|
15
15
|
export type SpawnANTParams = {
|
|
16
16
|
signer: AoSigner;
|
|
17
17
|
module?: string;
|
|
18
|
-
luaCodeTxId?: string;
|
|
19
18
|
ao?: AoClient;
|
|
20
19
|
scheduler?: string;
|
|
21
20
|
state?: SpawnANTState;
|
|
22
21
|
stateContractTxId?: string;
|
|
23
22
|
antRegistryId?: string;
|
|
24
23
|
logger?: Logger;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Compiled modules are now being used instead of luaCodeTxId
|
|
26
|
+
*/
|
|
27
|
+
luaCodeTxId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated no longer in use due to compiled modules being preferred
|
|
30
|
+
*/
|
|
25
31
|
arweave?: Arweave;
|
|
26
32
|
};
|
|
27
|
-
export declare function spawnANT({ signer, module,
|
|
33
|
+
export declare function spawnANT({ signer, module, ao, scheduler, state, stateContractTxId, antRegistryId, logger, }: SpawnANTParams): Promise<string>;
|
|
28
34
|
export declare function evolveANT({ signer, processId, luaCodeTxId, ao, logger, arweave, }: {
|
|
29
35
|
signer: AoSigner;
|
|
30
36
|
processId: string;
|
|
@@ -41,3 +47,7 @@ export declare function initANTStateForAddress({ owner, targetId, ttlSeconds, ke
|
|
|
41
47
|
ttlSeconds?: number;
|
|
42
48
|
owner: WalletAddress;
|
|
43
49
|
}): SpawnANTState;
|
|
50
|
+
/**
|
|
51
|
+
* Uses zod schema to parse the epoch data
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseAoEpochData(value: unknown): AoEpochData;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import Arweave from 'arweave';
|
|
1
17
|
import { BlockHeight } from '../types/common.js';
|
|
2
|
-
import { PaginationParams } from '../types/io.js';
|
|
18
|
+
import { AoEpochData, PaginationParams } from '../types/io.js';
|
|
3
19
|
export declare const validateArweaveId: (id: string) => boolean;
|
|
4
20
|
export declare function isBlockHeight(height: string | number): height is BlockHeight;
|
|
5
21
|
/**
|
|
@@ -18,3 +34,17 @@ export declare const paginationParamsToTags: <T>(params?: PaginationParams<T>) =
|
|
|
18
34
|
name: string;
|
|
19
35
|
value: string;
|
|
20
36
|
}[];
|
|
37
|
+
/**
|
|
38
|
+
* Get the epoch with distribution data for the current epoch
|
|
39
|
+
* @param arweave - The Arweave instance
|
|
40
|
+
* @returns The epoch with distribution data
|
|
41
|
+
*/
|
|
42
|
+
export declare const getEpochDataFromGql: ({ arweave, epochIndex, processId, }: {
|
|
43
|
+
arweave: Arweave;
|
|
44
|
+
epochIndex: number;
|
|
45
|
+
processId?: string;
|
|
46
|
+
}) => Promise<AoEpochData | undefined>;
|
|
47
|
+
export declare const epochDistributionNoticeGqlQuery: ({ epochIndex, processId, }: {
|
|
48
|
+
epochIndex: number;
|
|
49
|
+
processId?: string;
|
|
50
|
+
}) => string;
|
package/lib/types/version.d.ts
CHANGED