@tari-project/tarijs 0.1.21 → 0.1.22

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.
Files changed (109) hide show
  1. package/dist/builders/helpers/index.d.ts +2 -0
  2. package/dist/builders/helpers/index.js +2 -0
  3. package/dist/builders/helpers/submitTransaction.d.ts +13 -0
  4. package/dist/builders/helpers/submitTransaction.js +59 -0
  5. package/dist/builders/helpers/workspace.d.ts +23 -0
  6. package/dist/builders/helpers/workspace.js +29 -0
  7. package/dist/builders/index.d.ts +3 -0
  8. package/dist/builders/index.js +3 -0
  9. package/dist/builders/transaction/TransactionBuilder.d.ts +44 -0
  10. package/dist/builders/transaction/TransactionBuilder.js +164 -0
  11. package/dist/builders/transaction/TransactionRequest.d.ts +27 -0
  12. package/dist/builders/transaction/TransactionRequest.js +67 -0
  13. package/dist/builders/transaction/index.d.ts +2 -0
  14. package/dist/builders/transaction/index.js +2 -0
  15. package/dist/builders/types/Amount.d.ts +23 -0
  16. package/dist/builders/types/Amount.js +93 -0
  17. package/dist/builders/types/Arg.d.ts +1 -0
  18. package/dist/builders/types/Arg.js +1 -0
  19. package/dist/builders/types/Builder.d.ts +47 -0
  20. package/dist/builders/types/Builder.js +1 -0
  21. package/dist/builders/types/ComponentAddress.d.ts +1 -0
  22. package/dist/builders/types/ComponentAddress.js +1 -0
  23. package/dist/builders/types/ConfidentialClaim.d.ts +8 -0
  24. package/dist/builders/types/ConfidentialClaim.js +1 -0
  25. package/dist/builders/types/ConfidentialOutput.d.ts +8 -0
  26. package/dist/builders/types/ConfidentialOutput.js +1 -0
  27. package/dist/builders/types/ConfidentialOutputStatement.d.ts +9 -0
  28. package/dist/builders/types/ConfidentialOutputStatement.js +1 -0
  29. package/dist/builders/types/ConfidentialStatement.d.ts +8 -0
  30. package/dist/builders/types/ConfidentialStatement.js +1 -0
  31. package/dist/builders/types/ConfidentialWithdrawProof.d.ts +7 -0
  32. package/dist/builders/types/ConfidentialWithdrawProof.js +1 -0
  33. package/dist/builders/types/ElgamalVerifiableBalance.d.ts +4 -0
  34. package/dist/builders/types/ElgamalVerifiableBalance.js +1 -0
  35. package/dist/builders/types/Epoch.d.ts +1 -0
  36. package/dist/builders/types/Epoch.js +1 -0
  37. package/dist/builders/types/FinalizeResult.d.ts +20 -0
  38. package/dist/builders/types/FinalizeResult.js +1 -0
  39. package/dist/builders/types/Instruction.d.ts +56 -0
  40. package/dist/builders/types/Instruction.js +1 -0
  41. package/dist/builders/types/ResourceAddress.d.ts +1 -0
  42. package/dist/builders/types/ResourceAddress.js +2 -0
  43. package/dist/builders/types/SubstateDiff.d.ts +7 -0
  44. package/dist/builders/types/SubstateDiff.js +1 -0
  45. package/dist/builders/types/SubstateRequirement.d.ts +5 -0
  46. package/dist/builders/types/SubstateRequirement.js +1 -0
  47. package/dist/builders/types/TemplateAddress.d.ts +1 -0
  48. package/dist/builders/types/TemplateAddress.js +2 -0
  49. package/dist/builders/types/Transaction.d.ts +15 -0
  50. package/dist/builders/types/Transaction.js +1 -0
  51. package/dist/builders/types/TransactionId.d.ts +1 -0
  52. package/dist/builders/types/TransactionId.js +1 -0
  53. package/dist/builders/types/TransactionResult.d.ts +22 -0
  54. package/dist/builders/types/TransactionResult.js +10 -0
  55. package/dist/builders/types/TransactionSignature.d.ts +4 -0
  56. package/dist/builders/types/TransactionSignature.js +1 -0
  57. package/dist/builders/types/UnsignedTransaction.d.ts +12 -0
  58. package/dist/builders/types/UnsignedTransaction.js +1 -0
  59. package/dist/builders/types/VersionedSubstateId.d.ts +5 -0
  60. package/dist/builders/types/VersionedSubstateId.js +1 -0
  61. package/dist/builders/types/ViewableBalanceProof.d.ts +10 -0
  62. package/dist/builders/types/ViewableBalanceProof.js +2 -0
  63. package/dist/builders/types/Workspace.d.ts +3 -0
  64. package/dist/builders/types/Workspace.js +1 -0
  65. package/dist/builders/types/index.d.ts +24 -0
  66. package/dist/builders/types/index.js +2 -0
  67. package/dist/index.d.ts +13 -0
  68. package/dist/index.js +12 -0
  69. package/dist/providers/index.d.ts +16 -0
  70. package/dist/providers/index.js +1 -0
  71. package/dist/providers/metamask/index.d.ts +30 -0
  72. package/dist/providers/metamask/index.js +169 -0
  73. package/dist/providers/metamask/utils.d.ts +38 -0
  74. package/dist/providers/metamask/utils.js +55 -0
  75. package/dist/providers/tari_universe/index.d.ts +3 -0
  76. package/dist/providers/tari_universe/index.js +3 -0
  77. package/dist/providers/tari_universe/provider.d.ts +23 -0
  78. package/dist/providers/tari_universe/provider.js +88 -0
  79. package/dist/providers/tari_universe/types.d.ts +30 -0
  80. package/dist/providers/tari_universe/types.js +1 -0
  81. package/dist/providers/types.d.ts +66 -0
  82. package/dist/providers/types.js +10 -0
  83. package/dist/providers/wallet_daemon/index.d.ts +3 -0
  84. package/dist/providers/wallet_daemon/index.js +3 -0
  85. package/dist/providers/wallet_daemon/provider.d.ts +35 -0
  86. package/dist/providers/wallet_daemon/provider.js +173 -0
  87. package/dist/providers/wallet_daemon/tari_permissions.d.ts +216 -0
  88. package/dist/providers/wallet_daemon/tari_permissions.js +282 -0
  89. package/dist/providers/wallet_daemon/webrtc.d.ts +20 -0
  90. package/dist/providers/wallet_daemon/webrtc.js +201 -0
  91. package/dist/providers/wallet_daemon/webrtc_transport.d.ts +10 -0
  92. package/dist/providers/wallet_daemon/webrtc_transport.js +18 -0
  93. package/dist/providers/walletconnect/index.d.ts +23 -0
  94. package/dist/providers/walletconnect/index.js +217 -0
  95. package/dist/templates/Account.d.ts +65 -0
  96. package/dist/templates/Account.js +31 -0
  97. package/dist/templates/Pool.d.ts +30 -0
  98. package/dist/templates/Pool.js +20 -0
  99. package/dist/templates/Tariswap.d.ts +65 -0
  100. package/dist/templates/Tariswap.js +36 -0
  101. package/dist/templates/TemplateFactory.d.ts +9 -0
  102. package/dist/templates/TemplateFactory.js +18 -0
  103. package/dist/templates/TestFaucet.d.ts +49 -0
  104. package/dist/templates/TestFaucet.js +31 -0
  105. package/dist/templates/index.d.ts +4 -0
  106. package/dist/templates/index.js +4 -0
  107. package/dist/utils.d.ts +2 -0
  108. package/dist/utils.js +22 -0
  109. package/package.json +8 -4
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ export { AccountTemplate } from "./Account";
2
+ export { TariswapTemplate } from "./Tariswap";
3
+ export { PoolTemplate } from "./Pool";
4
+ export { TestFaucet } from "./TestFaucet";
@@ -0,0 +1,4 @@
1
+ export { AccountTemplate } from "./Account";
2
+ export { TariswapTemplate } from "./Tariswap";
3
+ export { PoolTemplate } from "./Pool";
4
+ export { TestFaucet } from "./TestFaucet";
@@ -0,0 +1,2 @@
1
+ export declare function toHexString(byteArray: any): string;
2
+ export declare function fromHexString(hexString: string): number[];
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.21",
3
+ "version": "0.1.22",
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
  },
@@ -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
  }