@tari-project/tarijs 0.1.21 → 0.1.23
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/builders/helpers/index.d.ts +2 -0
- package/dist/builders/helpers/index.js +2 -0
- package/dist/builders/helpers/submitTransaction.d.ts +13 -0
- package/dist/builders/helpers/submitTransaction.js +59 -0
- package/dist/builders/helpers/workspace.d.ts +23 -0
- package/dist/builders/helpers/workspace.js +29 -0
- package/dist/builders/index.d.ts +3 -0
- package/dist/builders/index.js +3 -0
- package/dist/builders/transaction/TransactionBuilder.d.ts +44 -0
- package/dist/builders/transaction/TransactionBuilder.js +164 -0
- package/dist/builders/transaction/TransactionRequest.d.ts +27 -0
- package/dist/builders/transaction/TransactionRequest.js +67 -0
- package/dist/builders/transaction/index.d.ts +2 -0
- package/dist/builders/transaction/index.js +2 -0
- package/dist/builders/types/Amount.d.ts +23 -0
- package/dist/builders/types/Amount.js +93 -0
- package/dist/builders/types/Arg.d.ts +1 -0
- package/dist/builders/types/Arg.js +1 -0
- package/dist/builders/types/Builder.d.ts +47 -0
- package/dist/builders/types/Builder.js +1 -0
- package/dist/builders/types/ComponentAddress.d.ts +1 -0
- package/dist/builders/types/ComponentAddress.js +1 -0
- package/dist/builders/types/ConfidentialClaim.d.ts +8 -0
- package/dist/builders/types/ConfidentialClaim.js +1 -0
- package/dist/builders/types/ConfidentialOutput.d.ts +8 -0
- package/dist/builders/types/ConfidentialOutput.js +1 -0
- package/dist/builders/types/ConfidentialOutputStatement.d.ts +9 -0
- package/dist/builders/types/ConfidentialOutputStatement.js +1 -0
- package/dist/builders/types/ConfidentialStatement.d.ts +8 -0
- package/dist/builders/types/ConfidentialStatement.js +1 -0
- package/dist/builders/types/ConfidentialWithdrawProof.d.ts +7 -0
- package/dist/builders/types/ConfidentialWithdrawProof.js +1 -0
- package/dist/builders/types/ElgamalVerifiableBalance.d.ts +4 -0
- package/dist/builders/types/ElgamalVerifiableBalance.js +1 -0
- package/dist/builders/types/Epoch.d.ts +1 -0
- package/dist/builders/types/Epoch.js +1 -0
- package/dist/builders/types/FinalizeResult.d.ts +20 -0
- package/dist/builders/types/FinalizeResult.js +1 -0
- package/dist/builders/types/Instruction.d.ts +56 -0
- package/dist/builders/types/Instruction.js +1 -0
- package/dist/builders/types/ResourceAddress.d.ts +1 -0
- package/dist/builders/types/ResourceAddress.js +2 -0
- package/dist/builders/types/SubstateDiff.d.ts +7 -0
- package/dist/builders/types/SubstateDiff.js +1 -0
- package/dist/builders/types/SubstateRequirement.d.ts +5 -0
- package/dist/builders/types/SubstateRequirement.js +1 -0
- package/dist/builders/types/TemplateAddress.d.ts +1 -0
- package/dist/builders/types/TemplateAddress.js +2 -0
- package/dist/builders/types/Transaction.d.ts +15 -0
- package/dist/builders/types/Transaction.js +1 -0
- package/dist/builders/types/TransactionId.d.ts +1 -0
- package/dist/builders/types/TransactionId.js +1 -0
- package/dist/builders/types/TransactionResult.d.ts +22 -0
- package/dist/builders/types/TransactionResult.js +10 -0
- package/dist/builders/types/TransactionSignature.d.ts +4 -0
- package/dist/builders/types/TransactionSignature.js +1 -0
- package/dist/builders/types/UnsignedTransaction.d.ts +12 -0
- package/dist/builders/types/UnsignedTransaction.js +1 -0
- package/dist/builders/types/VersionedSubstateId.d.ts +5 -0
- package/dist/builders/types/VersionedSubstateId.js +1 -0
- package/dist/builders/types/ViewableBalanceProof.d.ts +10 -0
- package/dist/builders/types/ViewableBalanceProof.js +2 -0
- package/dist/builders/types/Workspace.d.ts +3 -0
- package/dist/builders/types/Workspace.js +1 -0
- package/dist/builders/types/index.d.ts +24 -0
- package/dist/builders/types/index.js +2 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/providers/index.d.ts +16 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/metamask/index.d.ts +30 -0
- package/dist/providers/metamask/index.js +169 -0
- package/dist/providers/metamask/utils.d.ts +38 -0
- package/dist/providers/metamask/utils.js +55 -0
- package/dist/providers/tari_universe/index.d.ts +3 -0
- package/dist/providers/tari_universe/index.js +3 -0
- package/dist/providers/tari_universe/provider.d.ts +23 -0
- package/dist/providers/tari_universe/provider.js +88 -0
- package/dist/providers/tari_universe/types.d.ts +30 -0
- package/dist/providers/tari_universe/types.js +1 -0
- package/dist/providers/types.d.ts +66 -0
- package/dist/providers/types.js +10 -0
- package/dist/providers/wallet_daemon/index.d.ts +3 -0
- package/dist/providers/wallet_daemon/index.js +3 -0
- package/dist/providers/wallet_daemon/provider.d.ts +35 -0
- package/dist/providers/wallet_daemon/provider.js +173 -0
- package/dist/providers/wallet_daemon/tari_permissions.d.ts +216 -0
- package/dist/providers/wallet_daemon/tari_permissions.js +282 -0
- package/dist/providers/wallet_daemon/webrtc.d.ts +20 -0
- package/dist/providers/wallet_daemon/webrtc.js +201 -0
- package/dist/providers/wallet_daemon/webrtc_transport.d.ts +10 -0
- package/dist/providers/wallet_daemon/webrtc_transport.js +18 -0
- package/dist/providers/walletconnect/index.d.ts +23 -0
- package/dist/providers/walletconnect/index.js +217 -0
- package/dist/templates/Account.d.ts +65 -0
- package/dist/templates/Account.js +31 -0
- package/dist/templates/Pool.d.ts +30 -0
- package/dist/templates/Pool.js +20 -0
- package/dist/templates/Tariswap.d.ts +65 -0
- package/dist/templates/Tariswap.js +36 -0
- package/dist/templates/TemplateFactory.d.ts +9 -0
- package/dist/templates/TemplateFactory.js +18 -0
- package/dist/templates/TestFaucet.d.ts +49 -0
- package/dist/templates/TestFaucet.js +31 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/index.js +4 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +22 -0
- package/package.json +9 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
+
export class TariswapTemplate extends TemplateFactory {
|
|
3
|
+
templateAddress;
|
|
4
|
+
newPool;
|
|
5
|
+
mint;
|
|
6
|
+
mintWithSymbol;
|
|
7
|
+
totalSupply;
|
|
8
|
+
payFee;
|
|
9
|
+
payFeeConfidential;
|
|
10
|
+
withdraw;
|
|
11
|
+
addLiquidity;
|
|
12
|
+
removeLiquidity;
|
|
13
|
+
deposit;
|
|
14
|
+
swap;
|
|
15
|
+
constructor(templateAddress) {
|
|
16
|
+
super(templateAddress);
|
|
17
|
+
this.templateAddress = templateAddress;
|
|
18
|
+
this._initFunctions();
|
|
19
|
+
this._initMethods();
|
|
20
|
+
}
|
|
21
|
+
_initFunctions() {
|
|
22
|
+
this.newPool = this._defineFunction("new");
|
|
23
|
+
this.mint = this._defineFunction("mint");
|
|
24
|
+
this.mintWithSymbol = this._defineFunction("mint_with_symbol");
|
|
25
|
+
}
|
|
26
|
+
_initMethods() {
|
|
27
|
+
this.totalSupply = this._defineMethod("total_supply");
|
|
28
|
+
this.payFee = this._defineMethod("pay_fee");
|
|
29
|
+
this.payFeeConfidential = this._defineMethod("pay_fee_confidential");
|
|
30
|
+
this.withdraw = this._defineMethod("withdraw");
|
|
31
|
+
this.addLiquidity = this._defineMethod("add_liquidity");
|
|
32
|
+
this.removeLiquidity = this._defineMethod("remove_liquidity");
|
|
33
|
+
this.deposit = this._defineMethod("deposit");
|
|
34
|
+
this.swap = this._defineMethod("swap");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TariFunctionDefinition, TariMethodDefinition } from "../builders/types";
|
|
2
|
+
export declare abstract class TemplateFactory {
|
|
3
|
+
templateAddress: string;
|
|
4
|
+
constructor(templateAddress: string);
|
|
5
|
+
_defineFunction<T extends TariFunctionDefinition>(name: T["functionName"]): T;
|
|
6
|
+
_defineMethod<T extends TariMethodDefinition>(name: T["methodName"]): T;
|
|
7
|
+
protected abstract _initFunctions(): void;
|
|
8
|
+
protected abstract _initMethods(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class TemplateFactory {
|
|
2
|
+
templateAddress;
|
|
3
|
+
constructor(templateAddress) {
|
|
4
|
+
this.templateAddress = templateAddress;
|
|
5
|
+
}
|
|
6
|
+
_defineFunction(name) {
|
|
7
|
+
return {
|
|
8
|
+
templateAddress: this.templateAddress,
|
|
9
|
+
functionName: name,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
_defineMethod(name) {
|
|
13
|
+
return {
|
|
14
|
+
componentAddress: this.templateAddress,
|
|
15
|
+
methodName: name,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Amount, ConfidentialWithdrawProof, TariFunctionDefinition, TariMethodDefinition } from "../builders/types";
|
|
2
|
+
import { TemplateFactory } from "./TemplateFactory";
|
|
3
|
+
interface MintFunction extends TariFunctionDefinition {
|
|
4
|
+
functionName: "mint";
|
|
5
|
+
args?: [string];
|
|
6
|
+
}
|
|
7
|
+
interface MintWithSymbolFunction extends TariFunctionDefinition {
|
|
8
|
+
functionName: "mint_with_symbol";
|
|
9
|
+
args?: [amount: string, symbol: string];
|
|
10
|
+
}
|
|
11
|
+
interface PayFeeMethod extends TariMethodDefinition {
|
|
12
|
+
methodName: "pay_fee";
|
|
13
|
+
args?: [Amount];
|
|
14
|
+
}
|
|
15
|
+
interface PayFeeConfidentialMethod extends TariMethodDefinition {
|
|
16
|
+
methodName: "pay_fee_confidential";
|
|
17
|
+
args?: [ConfidentialWithdrawProof];
|
|
18
|
+
}
|
|
19
|
+
interface TakeFreeCoinsMethod extends TariMethodDefinition {
|
|
20
|
+
methodName: "take_free_coins";
|
|
21
|
+
args?: [];
|
|
22
|
+
}
|
|
23
|
+
interface TakeFreeCoinsConfidentialMethod extends TariMethodDefinition {
|
|
24
|
+
methodName: "take_free_coins_confidential";
|
|
25
|
+
args?: [ConfidentialWithdrawProof];
|
|
26
|
+
}
|
|
27
|
+
interface BurnCoinsMethod extends TariMethodDefinition {
|
|
28
|
+
methodName: "burn_coins";
|
|
29
|
+
args?: [BigInt];
|
|
30
|
+
}
|
|
31
|
+
interface TotalSupplyMethod extends TariMethodDefinition {
|
|
32
|
+
methodName: "total_supply";
|
|
33
|
+
args?: [];
|
|
34
|
+
}
|
|
35
|
+
export declare class TestFaucet extends TemplateFactory {
|
|
36
|
+
templateAddress: string;
|
|
37
|
+
mint: MintFunction;
|
|
38
|
+
mintWithSymbol: MintWithSymbolFunction;
|
|
39
|
+
takeFreeCoins: TakeFreeCoinsMethod;
|
|
40
|
+
takeFreeCoinsConfidential: TakeFreeCoinsConfidentialMethod;
|
|
41
|
+
burnCoins: BurnCoinsMethod;
|
|
42
|
+
totalSupply: TotalSupplyMethod;
|
|
43
|
+
payFee: PayFeeMethod;
|
|
44
|
+
payFeeConfidential: PayFeeConfidentialMethod;
|
|
45
|
+
constructor(templateAddress: string);
|
|
46
|
+
protected _initFunctions(): void;
|
|
47
|
+
protected _initMethods(): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
+
export class TestFaucet extends TemplateFactory {
|
|
3
|
+
templateAddress;
|
|
4
|
+
mint;
|
|
5
|
+
mintWithSymbol;
|
|
6
|
+
takeFreeCoins;
|
|
7
|
+
takeFreeCoinsConfidential;
|
|
8
|
+
burnCoins;
|
|
9
|
+
totalSupply;
|
|
10
|
+
payFee;
|
|
11
|
+
payFeeConfidential;
|
|
12
|
+
constructor(templateAddress) {
|
|
13
|
+
super(templateAddress);
|
|
14
|
+
this.templateAddress = templateAddress;
|
|
15
|
+
this._initFunctions();
|
|
16
|
+
this._initMethods();
|
|
17
|
+
}
|
|
18
|
+
_initFunctions() {
|
|
19
|
+
this.mint = this._defineFunction("mint");
|
|
20
|
+
this.mintWithSymbol = this._defineFunction("mint_with_symbol");
|
|
21
|
+
}
|
|
22
|
+
_initMethods() {
|
|
23
|
+
this.takeFreeCoins = this._defineMethod("take_free_coins");
|
|
24
|
+
this.takeFreeCoinsConfidential =
|
|
25
|
+
this._defineMethod("take_free_coins_confidential");
|
|
26
|
+
this.burnCoins = this._defineMethod("burn_coins");
|
|
27
|
+
this.totalSupply = this._defineMethod("total_supply");
|
|
28
|
+
this.payFee = this._defineMethod("pay_fee");
|
|
29
|
+
this.payFeeConfidential = this._defineMethod("pay_fee_confidential");
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function toHexString(byteArray) {
|
|
2
|
+
if (Array.isArray(byteArray)) {
|
|
3
|
+
return Array.from(byteArray, function (byte) {
|
|
4
|
+
return ('0' + (byte & 0xff).toString(16)).slice(-2);
|
|
5
|
+
}).join('');
|
|
6
|
+
}
|
|
7
|
+
if (byteArray === undefined) {
|
|
8
|
+
return 'undefined';
|
|
9
|
+
}
|
|
10
|
+
// object might be a tagged object
|
|
11
|
+
if (byteArray['@@TAGGED@@'] !== undefined) {
|
|
12
|
+
return toHexString(byteArray['@@TAGGED@@'][1]);
|
|
13
|
+
}
|
|
14
|
+
return 'Unsupported type';
|
|
15
|
+
}
|
|
16
|
+
export function fromHexString(hexString) {
|
|
17
|
+
let res = [];
|
|
18
|
+
for (let i = 0; i < hexString.length; i += 2) {
|
|
19
|
+
res.push(Number('0x' + hexString.substring(i, i + 2)));
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "./src/index.js",
|
|
6
5
|
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
7
9
|
"scripts": {
|
|
8
10
|
"build": "tsc -b"
|
|
9
11
|
},
|
|
@@ -13,7 +15,7 @@
|
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"@metamask/providers": "^9.0.0",
|
|
15
17
|
"@tari-project/wallet_jrpc_client": "^1.0.8",
|
|
16
|
-
"@tari-project/typescript-bindings": "^1.0.
|
|
18
|
+
"@tari-project/typescript-bindings": "^1.0.6",
|
|
17
19
|
"@walletconnect/modal": "^2.6.2",
|
|
18
20
|
"@walletconnect/universal-provider": "^2.13.3"
|
|
19
21
|
},
|
|
@@ -22,6 +24,8 @@
|
|
|
22
24
|
"typescript": "^5.0.4"
|
|
23
25
|
},
|
|
24
26
|
"files": [
|
|
25
|
-
"dist"
|
|
26
|
-
]
|
|
27
|
+
"/dist"
|
|
28
|
+
],
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts"
|
|
27
31
|
}
|