@tari-project/tarijs-types 0.5.3 → 0.5.5
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/dist/Instruction.d.ts +8 -2
- package/dist/SubstateType.d.ts +1 -0
- package/dist/SubstateType.js +1 -0
- package/dist/TransactionResult.d.ts +11 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/txResult.d.ts +29 -0
- package/dist/helpers/txResult.js +46 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/Instruction.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComponentAddress, LogLevel, PublishedTemplateAddress } from "@tari-project/typescript-bindings";
|
|
1
|
+
import { ComponentAddress, LogLevel, PublishedTemplateAddress, SubstateType } from "@tari-project/typescript-bindings";
|
|
2
2
|
import { TransactionArg } from "./TransactionArg";
|
|
3
3
|
import { ConfidentialClaim } from "./ConfidentialClaim";
|
|
4
4
|
import { Amount } from "./Amount";
|
|
5
5
|
import { ConfidentialOutput } from "./ConfidentialOutput";
|
|
6
|
-
export type Instruction = CreateAccount | CallFunction | CallMethod | PutLastInstructionOutputOnWorkspace | EmitLog | ClaimBurn | ClaimValidatorFees | DropAllProofsInWorkspace | CreateFreeTestCoins;
|
|
6
|
+
export type Instruction = CreateAccount | CallFunction | CallMethod | PutLastInstructionOutputOnWorkspace | EmitLog | ClaimBurn | ClaimValidatorFees | DropAllProofsInWorkspace | CreateFreeTestCoins | AllocateAddress;
|
|
7
7
|
export type CreateAccount = {
|
|
8
8
|
CreateAccount: {
|
|
9
9
|
owner_public_key: string;
|
|
@@ -53,3 +53,9 @@ export type CreateFreeTestCoins = {
|
|
|
53
53
|
output: ConfidentialOutput | null;
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
+
export type AllocateAddress = {
|
|
57
|
+
AllocateAddress: {
|
|
58
|
+
substate_type: SubstateType;
|
|
59
|
+
workspace_id: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SubstateType = "Component" | "Resource" | "Vault" | "UnclaimedConfidentialOutput" | "NonFungible" | "TransactionReceipt" | "NonFungibleIndex" | "ValidatorFeePool" | "Template";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { TransactionStatus } from "./TransactionStatus";
|
|
2
2
|
import { FinalizeResult } from "./FinalizeResult";
|
|
3
|
+
import { DownSubstates, UpSubstates } from "./SubstateDiff";
|
|
4
|
+
import { ComponentAddress } from "@tari-project/typescript-bindings";
|
|
3
5
|
export type SubmitTransactionResponse = {
|
|
4
6
|
transaction_id: string;
|
|
5
7
|
};
|
|
6
8
|
export interface SubmitTxResult {
|
|
7
9
|
response: SubmitTransactionResponse;
|
|
8
10
|
result: TransactionResult;
|
|
11
|
+
upSubstates: UpSubstates;
|
|
12
|
+
downSubstates: DownSubstates;
|
|
13
|
+
newComponents: UpSubstates;
|
|
14
|
+
getComponentForTemplate(templateAddress: string): ComponentAddress | null;
|
|
9
15
|
}
|
|
10
16
|
export type TransactionResult = {
|
|
11
17
|
transaction_id: string;
|
|
12
18
|
status: TransactionStatus;
|
|
13
19
|
result: FinalizeResult | null;
|
|
14
20
|
};
|
|
21
|
+
export type TransactionResultResponse = {
|
|
22
|
+
transaction_id: string;
|
|
23
|
+
status: TransactionStatus;
|
|
24
|
+
result: FinalizeResult | null;
|
|
25
|
+
};
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NonFungibleId, NonFungibleToken, ResourceAddress } from "@tari-project/typescript-bindings";
|
|
2
2
|
import { TransactionStatus } from "../TransactionStatus";
|
|
3
3
|
export { fromHexString, toHexString } from "./hexString";
|
|
4
|
+
export { txResultCheck, getSubstateValueFromUpSubstates, getComponentsForTemplate } from "./txResult";
|
|
4
5
|
export { BinaryTag, CborValue, convertTaggedValue, getCborValueByPath, parseCbor } from "./cbor";
|
|
5
6
|
export { substateIdToString, stringToSubstateId, shortenSubstateId, shortenString, rejectReasonToString, getSubstateDiffFromTransactionResult, getRejectReasonFromTransactionResult, jrpcPermissionToString, } from "@tari-project/typescript-bindings";
|
|
6
7
|
export declare function convertStringToTransactionStatus(status: string): TransactionStatus;
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TransactionStatus } from "../TransactionStatus";
|
|
2
2
|
export { fromHexString, toHexString } from "./hexString";
|
|
3
|
+
export { txResultCheck, getSubstateValueFromUpSubstates, getComponentsForTemplate } from "./txResult";
|
|
3
4
|
export { BinaryTag, convertTaggedValue, getCborValueByPath, parseCbor } from "./cbor";
|
|
4
5
|
export { substateIdToString, stringToSubstateId, shortenSubstateId, shortenString, rejectReasonToString, getSubstateDiffFromTransactionResult, getRejectReasonFromTransactionResult, jrpcPermissionToString, } from "@tari-project/typescript-bindings";
|
|
5
6
|
export function convertStringToTransactionStatus(status) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SubstateDiff, VaultId, Vault, SubstateId, SubstateValue, ResourceContainer, ResourceAddress, Amount, RejectReason, ComponentAddress } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { FinalizeResultStatus } from "../FinalizeResult";
|
|
3
|
+
import { UpSubstates } from "../SubstateDiff";
|
|
4
|
+
export declare const txResultCheck: {
|
|
5
|
+
isAccept: (result: FinalizeResultStatus) => result is {
|
|
6
|
+
Accept: SubstateDiff;
|
|
7
|
+
};
|
|
8
|
+
isVaultId: (substateId: SubstateId) => substateId is {
|
|
9
|
+
Vault: VaultId;
|
|
10
|
+
};
|
|
11
|
+
isVaultSubstate: (substate: SubstateValue) => substate is {
|
|
12
|
+
Vault: Vault;
|
|
13
|
+
};
|
|
14
|
+
isFungible: (resourceContainer: ResourceContainer) => resourceContainer is {
|
|
15
|
+
Fungible: {
|
|
16
|
+
address: ResourceAddress;
|
|
17
|
+
amount: Amount;
|
|
18
|
+
locked_amount: Amount;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
isReject: (result: FinalizeResultStatus) => result is {
|
|
22
|
+
Reject: RejectReason;
|
|
23
|
+
};
|
|
24
|
+
isAcceptFeeRejectRest: (result: FinalizeResultStatus) => result is {
|
|
25
|
+
AcceptFeeRejectRest: [SubstateDiff, RejectReason];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function getSubstateValueFromUpSubstates(substateType: keyof SubstateValue | string, upSubstates: UpSubstates): UpSubstates;
|
|
29
|
+
export declare function getComponentsForTemplate(templateAddress: string, upSubstates: UpSubstates): ComponentAddress[] | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { substateIdToString, } from "@tari-project/typescript-bindings";
|
|
2
|
+
function isOfType(obj, key) {
|
|
3
|
+
return obj !== null && typeof obj === "object" && key in obj;
|
|
4
|
+
}
|
|
5
|
+
export const txResultCheck = {
|
|
6
|
+
isAccept: (result) => {
|
|
7
|
+
return "Accept" in result;
|
|
8
|
+
},
|
|
9
|
+
isVaultId: (substateId) => {
|
|
10
|
+
return isOfType(substateId, "Vault");
|
|
11
|
+
},
|
|
12
|
+
isVaultSubstate: (substate) => {
|
|
13
|
+
return "Vault" in substate;
|
|
14
|
+
},
|
|
15
|
+
isFungible: (resourceContainer) => {
|
|
16
|
+
return "Fungible" in resourceContainer;
|
|
17
|
+
},
|
|
18
|
+
isReject: (result) => {
|
|
19
|
+
return "Reject" in result;
|
|
20
|
+
},
|
|
21
|
+
isAcceptFeeRejectRest: (result) => {
|
|
22
|
+
return "AcceptFeeRejectRest" in result;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export function getSubstateValueFromUpSubstates(substateType, upSubstates) {
|
|
26
|
+
const components = [];
|
|
27
|
+
for (const [substateId, substate] of upSubstates) {
|
|
28
|
+
if (substateType in substate.substate) {
|
|
29
|
+
components.push([substateId, substate]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return components;
|
|
33
|
+
}
|
|
34
|
+
export function getComponentsForTemplate(templateAddress, upSubstates) {
|
|
35
|
+
const components = [];
|
|
36
|
+
const templateAddressBytes = new TextEncoder().encode(templateAddress);
|
|
37
|
+
for (const [substateId, substate] of upSubstates) {
|
|
38
|
+
if ("Component" in substate.substate) {
|
|
39
|
+
const componentHeader = substate.substate.Component;
|
|
40
|
+
if (componentHeader.template_address === templateAddressBytes) {
|
|
41
|
+
components.push(substateIdToString(substateId));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return components;
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export { Instruction } from "./Instruction";
|
|
|
10
10
|
export { Transaction } from "./Transaction";
|
|
11
11
|
export { SubstateDiff, DownSubstates, UpSubstates } from "./SubstateDiff";
|
|
12
12
|
export { SubstateRequirement } from "./SubstateRequirement";
|
|
13
|
-
export {
|
|
13
|
+
export { SubstateType } from "./SubstateType";
|
|
14
|
+
export { TransactionResult, SubmitTxResult, SubmitTransactionResponse, TransactionResultResponse, } from "./TransactionResult";
|
|
14
15
|
export { TransactionSignature } from "./TransactionSignature";
|
|
15
16
|
export { TransactionStatus } from "./TransactionStatus";
|
|
16
17
|
export { UnsignedTransaction } from "./UnsignedTransaction";
|
|
@@ -19,4 +20,4 @@ export { WorkspaceArg } from "./Workspace";
|
|
|
19
20
|
export { ListAccountNftFromBalancesRequest } from "./ListAccountNftFromBalancesRequest";
|
|
20
21
|
export { Network } from "./network";
|
|
21
22
|
export { AccountData, ListSubstatesRequest, ListSubstatesResponse, SubmitTransactionRequest, Substate, SubstateMetadata, ReqSubstate, TemplateDefinition, VaultBalances, VaultData, GetSubstateRequest, } from "./signer";
|
|
22
|
-
export { convertHexStringToU256Array, convertStringToTransactionStatus, convertU256ToHexString, createNftAddressFromResource, createNftAddressFromToken, getRejectReasonFromTransactionResult, getSubstateDiffFromTransactionResult, jrpcPermissionToString, rejectReasonToString, shortenString, shortenSubstateId, stringToSubstateId, substateIdToString, fromHexString, toHexString, convertTaggedValue, getCborValueByPath, parseCbor, BinaryTag, CborValue, } from "./helpers";
|
|
23
|
+
export { convertHexStringToU256Array, convertStringToTransactionStatus, convertU256ToHexString, createNftAddressFromResource, createNftAddressFromToken, getRejectReasonFromTransactionResult, getSubstateDiffFromTransactionResult, jrpcPermissionToString, rejectReasonToString, shortenString, shortenSubstateId, stringToSubstateId, substateIdToString, fromHexString, toHexString, convertTaggedValue, getCborValueByPath, parseCbor, getSubstateValueFromUpSubstates, getComponentsForTemplate, txResultCheck, BinaryTag, CborValue, } from "./helpers";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Amount } from "./Amount";
|
|
2
2
|
export { TransactionStatus } from "./TransactionStatus";
|
|
3
3
|
export { Network } from "./network";
|
|
4
|
-
export { convertHexStringToU256Array, convertStringToTransactionStatus, convertU256ToHexString, createNftAddressFromResource, createNftAddressFromToken, getRejectReasonFromTransactionResult, getSubstateDiffFromTransactionResult, jrpcPermissionToString, rejectReasonToString, shortenString, shortenSubstateId, stringToSubstateId, substateIdToString, fromHexString, toHexString, convertTaggedValue, getCborValueByPath, parseCbor, BinaryTag, } from "./helpers";
|
|
4
|
+
export { convertHexStringToU256Array, convertStringToTransactionStatus, convertU256ToHexString, createNftAddressFromResource, createNftAddressFromToken, getRejectReasonFromTransactionResult, getSubstateDiffFromTransactionResult, jrpcPermissionToString, rejectReasonToString, shortenString, shortenSubstateId, stringToSubstateId, substateIdToString, fromHexString, toHexString, convertTaggedValue, getCborValueByPath, parseCbor, getSubstateValueFromUpSubstates, getComponentsForTemplate, txResultCheck, BinaryTag, } from "./helpers";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-types",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tari-project/typescript-bindings": "^1.5.
|
|
13
|
+
"@tari-project/typescript-bindings": "^1.5.5"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^22.13.1",
|