@warganetwork/sdk 0.0.0-stage → 1.4.0
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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +189 -2
- package/assets/logo-transparent.png +0 -0
- package/assets/wrg-256.png +0 -0
- package/assets/wrg-token.png +0 -0
- package/dist/index.cjs +660 -0
- package/examples/escrow/lock-and-release.js +38 -0
- package/examples/foundry/foundry.toml +10 -0
- package/examples/hardhat/hardhat.config.js +41 -0
- package/examples/kyc-badge/check-and-mint-badge.js +35 -0
- package/examples/merchant-webhook/verify-webhook.js +29 -0
- package/examples/quantum/mldsa65-sign-and-verify.js +54 -0
- package/examples/swap/quote-and-swap.js +39 -0
- package/openapi/warga-public-api.yaml +233 -0
- package/package.json +74 -4
- package/src/abis/IDRToken.abi.json +530 -0
- package/src/abis/JPYToken.abi.json +530 -0
- package/src/abis/MerchantEscrow.abi.json +581 -0
- package/src/abis/MerchantKYCBadgeNFT.abi.json +697 -0
- package/src/abis/QuantumGuardVault.abi.json +326 -0
- package/src/abis/USDTToken.abi.json +530 -0
- package/src/abis/ValidatorRegistry.abi.json +239 -0
- package/src/abis/WargaCoin.abi.json +478 -0
- package/src/abis/WargaSwapV3Pool.abi.json +768 -0
- package/src/abis/WrgVault.abi.json +299 -0
- package/src/abis/index.js +35 -0
- package/src/helpers.js +124 -0
- package/src/index.d.ts +150 -0
- package/src/index.js +536 -0
- package/tokenlist/warga.tokenlist.json +55 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated CommonJS bundle for @warganetwork/sdk v1.4.0
|
|
3
|
+
|
|
4
|
+
// Auto-generated pure-JS browser-compatible ABI bundle (Vyper 0.4.3+commit.bff19ea2 — v2.0.0-rc1)
|
|
5
|
+
// Pure JavaScript ESM exports — works natively in browsers, Edge runtimes, and Node.js.
|
|
6
|
+
|
|
7
|
+
const WargaCoinAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"FeeBurned","inputs":[{"name":"burner","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"EmergencyPauseToggled","inputs":[{"name":"paused","type":"bool","indexed":false}],"anonymous":false,"type":"event"},{"name":"GovernanceProposed","inputs":[{"name":"currentGovernance","type":"address","indexed":true},{"name":"pendingGovernance","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"GovernanceUpdated","inputs":[{"name":"previousGovernance","type":"address","indexed":true},{"name":"newGovernance","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"burn","inputs":[{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"propose_governance_multisig","inputs":[{"name":"_new_governance","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_governance_multisig","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint8"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"MAX_SUPPLY","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"POC_ECOSYSTEM_ALLOC","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"TREASURY_LP_ALLOC","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"VALIDATOR_STAKING_ALLOC","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"CORE_STRATEGIC_ALLOC","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"governance_multisig","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_governance_multisig","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"total_burned","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_poc_ecosystem_vault","type":"address"},{"name":"_treasury_lp_vault","type":"address"},{"name":"_validator_treasury","type":"address"},{"name":"_core_strategic_vault","type":"address"},{"name":"_governance_multisig","type":"address"}],"outputs":[]}]);
|
|
8
|
+
|
|
9
|
+
const WrgVaultAbi = Object.freeze([{"name":"Deposit","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"token","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"ProposalCreated","inputs":[{"name":"proposal_id","type":"uint256","indexed":true},{"name":"target","type":"address","indexed":true},{"name":"token","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false},{"name":"description","type":"string","indexed":false}],"anonymous":false,"type":"event"},{"name":"ProposalSigned","inputs":[{"name":"proposal_id","type":"uint256","indexed":true},{"name":"signer","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"ProposalExecuted","inputs":[{"name":"proposal_id","type":"uint256","indexed":true},{"name":"target","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"nonpayable","type":"function","name":"propose_transfer","inputs":[{"name":"target","type":"address"},{"name":"token","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"confirm_proposal","inputs":[{"name":"proposal_id","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"execute_proposal","inputs":[{"name":"proposal_id","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"is_signer","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"signers","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"threshold","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"proposals","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"tuple","components":[{"name":"target","type":"address"},{"name":"token","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"},{"name":"confirmations","type":"uint256"},{"name":"executed","type":"bool"}]}]},{"stateMutability":"view","type":"function","name":"proposal_signed","inputs":[{"name":"arg0","type":"uint256"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"proposal_count","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_signers","type":"address[]"},{"name":"_threshold","type":"uint256"}],"outputs":[]}]);
|
|
10
|
+
|
|
11
|
+
const MerchantEscrowAbi = Object.freeze([{"name":"EscrowLocked","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"buyer","type":"address","indexed":true},{"name":"merchant","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false},{"name":"expires_at","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"EscrowReleasedByBuyer","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"buyer","type":"address","indexed":true},{"name":"merchant","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"EscrowRefundedByMerchant","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"merchant","type":"address","indexed":true},{"name":"buyer","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false},{"name":"reason","type":"string","indexed":false}],"anonymous":false,"type":"event"},{"name":"EscrowExpiredClaimed","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"buyer","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"EscrowDisputed","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"opened_by","type":"address","indexed":true},{"name":"disputed_at","type":"uint256","indexed":false},{"name":"reason","type":"string","indexed":false}],"anonymous":false,"type":"event"},{"name":"DisputeResolvedByOperator","inputs":[{"name":"order_id","type":"bytes32","indexed":true},{"name":"operator","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false},{"name":"released_to_merchant","type":"bool","indexed":false},{"name":"resolution_note","type":"string","indexed":false}],"anonymous":false,"type":"event"},{"name":"OperatorProposed","inputs":[{"name":"current_operator","type":"address","indexed":true},{"name":"pending_operator","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"OperatorTransferred","inputs":[{"name":"previous_operator","type":"address","indexed":true},{"name":"new_operator","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"lock_order","inputs":[{"name":"order_id","type":"bytes32"},{"name":"merchant","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"lock_order_with_timeout","inputs":[{"name":"order_id","type":"bytes32"},{"name":"merchant","type":"address"},{"name":"amount","type":"uint256"},{"name":"timeout_sec","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"release_escrow","inputs":[{"name":"order_id","type":"bytes32"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"refund_escrow","inputs":[{"name":"order_id","type":"bytes32"},{"name":"reason","type":"string"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"claim_expired_order","inputs":[{"name":"order_id","type":"bytes32"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"open_dispute","inputs":[{"name":"order_id","type":"bytes32"},{"name":"reason","type":"string"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"resolve_dispute","inputs":[{"name":"order_id","type":"bytes32"},{"name":"release_to_merchant","type":"bool"},{"name":"resolution_note","type":"string"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"propose_operator","inputs":[{"name":"new_operator","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_operator","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"recover_stray_token","inputs":[{"name":"token","type":"address"},{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"MIN_TIMEOUT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DEFAULT_TIMEOUT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"MAX_TIMEOUT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DISPUTE_TIMELOCK","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"orders","inputs":[{"name":"arg0","type":"bytes32"}],"outputs":[{"name":"","type":"tuple","components":[{"name":"buyer","type":"address"},{"name":"merchant","type":"address"},{"name":"amount","type":"uint256"},{"name":"expires_at","type":"uint256"},{"name":"disputed_at","type":"uint256"},{"name":"is_active","type":"bool"},{"name":"is_settled","type":"bool"},{"name":"is_disputed","type":"bool"}]}]},{"stateMutability":"view","type":"function","name":"settlement_token","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"operator","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_operator","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_token","type":"address"},{"name":"_operator","type":"address"}],"outputs":[]}]);
|
|
12
|
+
|
|
13
|
+
const ValidatorRegistryAbi = Object.freeze([{"name":"ValidatorRegistered","inputs":[{"name":"val_id","type":"bytes32","indexed":true},{"name":"node_pubkey","type":"address","indexed":true},{"name":"voting_signer","type":"address","indexed":false},{"name":"treasury_authority","type":"address","indexed":false},{"name":"tier","type":"string","indexed":false},{"name":"stake_weight","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"ValidatorSlashed","inputs":[{"name":"val_id","type":"bytes32","indexed":true},{"name":"slasher","type":"address","indexed":true},{"name":"penalty_weight","type":"uint256","indexed":false},{"name":"reason","type":"string","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"register_validator","inputs":[{"name":"val_id","type":"bytes32"},{"name":"node_pubkey","type":"address"},{"name":"voting_signer","type":"address"},{"name":"treasury_authority","type":"address"},{"name":"tier","type":"string"},{"name":"region","type":"string"},{"name":"stake_weight","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"slash_validator","inputs":[{"name":"val_id","type":"bytes32"},{"name":"penalty","type":"uint256"},{"name":"reason","type":"string"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"validators","inputs":[{"name":"arg0","type":"bytes32"}],"outputs":[{"name":"","type":"tuple","components":[{"name":"node_pubkey","type":"address"},{"name":"voting_signer","type":"address"},{"name":"treasury_authority","type":"address"},{"name":"tier","type":"string"},{"name":"region","type":"string"},{"name":"stake_weight","type":"uint256"},{"name":"slashing_count","type":"uint256"},{"name":"is_active","type":"bool"},{"name":"is_jailed","type":"bool"}]}]},{"stateMutability":"view","type":"function","name":"validator_keys","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"bytes32"}]},{"stateMutability":"view","type":"function","name":"total_active_weight","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"governance","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_governance","type":"address"}],"outputs":[]}]);
|
|
14
|
+
|
|
15
|
+
const MerchantKYCBadgeNFTAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"tokenId","type":"uint256","indexed":true}],"anonymous":false,"type":"event"},{"name":"Locked","inputs":[{"name":"tokenId","type":"uint256","indexed":true}],"anonymous":false,"type":"event"},{"name":"Unlocked","inputs":[{"name":"tokenId","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"OwnershipProposed","inputs":[{"name":"currentOwner","type":"address","indexed":true},{"name":"pendingOwner","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"MerchantKYCBadgeMinted","inputs":[{"name":"tokenId","type":"uint256","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"storeId","type":"string","indexed":false},{"name":"storeName","type":"string","indexed":false},{"name":"kycHash","type":"string","indexed":false},{"name":"verifiedAt","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"MerchantKYCBadgeRevoked","inputs":[{"name":"tokenId","type":"uint256","indexed":true},{"name":"storeId","type":"string","indexed":false},{"name":"revokedBy","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"MinterUpdated","inputs":[{"name":"previousMinter","type":"address","indexed":true},{"name":"newMinter","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true},{"name":"newOwner","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"view","type":"function","name":"supportsInterface","inputs":[{"name":"interface_id","type":"bytes4"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"locked","inputs":[{"name":"tokenId","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"account","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"ownerOf","inputs":[{"name":"tokenId","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"tokenURI","inputs":[{"name":"tokenId","type":"uint256"}],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"getApproved","inputs":[{"name":"tokenId","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"isApprovedForAll","inputs":[{"name":"account","type":"address"},{"name":"operator","type":"address"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"setMinter","inputs":[{"name":"new_minter","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"transferOwnership","inputs":[{"name":"new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"mintBadge","inputs":[{"name":"recipient","type":"address"},{"name":"store_id","type":"string"},{"name":"store_name","type":"string"},{"name":"kyc_hash","type":"string"},{"name":"metadata_uri","type":"string"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"revokeBadge","inputs":[{"name":"tokenId","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"approved","type":"address"},{"name":"tokenId","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address"},{"name":"approved","type":"bool"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"sender","type":"address"},{"name":"receiver","type":"address"},{"name":"tokenId","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"safeTransferFrom","inputs":[{"name":"sender","type":"address"},{"name":"receiver","type":"address"},{"name":"tokenId","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"safeTransferFrom","inputs":[{"name":"sender","type":"address"},{"name":"receiver","type":"address"},{"name":"tokenId","type":"uint256"},{"name":"data","type":"bytes"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"proposeOwnership","inputs":[{"name":"new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"acceptOwnership","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"minter","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"total_supply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"next_token_id","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"store_to_token_id","inputs":[{"name":"arg0","type":"string"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"token_to_store_id","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"store_name_of","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"kyc_hash_of","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"verified_at_of","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"is_store_verified","inputs":[{"name":"arg0","type":"string"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[],"outputs":[]}]);
|
|
16
|
+
|
|
17
|
+
const IDRTokenAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"MintApproved","inputs":[{"name":"caller","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"BurnApproved","inputs":[{"name":"burner","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"DailyMintLimitUpdated","inputs":[{"name":"previousLimit","type":"uint256","indexed":false},{"name":"newLimit","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"CustodianProposed","inputs":[{"name":"currentCustodian","type":"address","indexed":true},{"name":"pendingCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"CustodianUpdated","inputs":[{"name":"previousCustodian","type":"address","indexed":true},{"name":"newCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"EmergencyPauseToggled","inputs":[{"name":"paused","type":"bool","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"mint","inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"burn","inputs":[{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"set_daily_mint_limit","inputs":[{"name":"new_limit","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"propose_owner","inputs":[{"name":"_new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_owner","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"DAY_SECONDS","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DEFAULT_DAILY_MINT_LIMIT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint8"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"daily_mint_limit","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"mint_window_start","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"minted_in_window","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_initial_owner","type":"address"},{"name":"_initial_recipient","type":"address"},{"name":"_initial_supply","type":"uint256"}],"outputs":[]}]);
|
|
18
|
+
|
|
19
|
+
const USDTTokenAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"MintApproved","inputs":[{"name":"caller","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"BurnApproved","inputs":[{"name":"burner","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"DailyMintLimitUpdated","inputs":[{"name":"previousLimit","type":"uint256","indexed":false},{"name":"newLimit","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"CustodianProposed","inputs":[{"name":"currentCustodian","type":"address","indexed":true},{"name":"pendingCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"CustodianUpdated","inputs":[{"name":"previousCustodian","type":"address","indexed":true},{"name":"newCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"EmergencyPauseToggled","inputs":[{"name":"paused","type":"bool","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"mint","inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"burn","inputs":[{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"set_daily_mint_limit","inputs":[{"name":"new_limit","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"propose_owner","inputs":[{"name":"_new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_owner","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"DAY_SECONDS","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DEFAULT_DAILY_MINT_LIMIT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint8"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"daily_mint_limit","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"mint_window_start","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"minted_in_window","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_initial_owner","type":"address"},{"name":"_initial_recipient","type":"address"},{"name":"_initial_supply","type":"uint256"}],"outputs":[]}]);
|
|
20
|
+
|
|
21
|
+
const JPYTokenAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"MintApproved","inputs":[{"name":"caller","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"BurnApproved","inputs":[{"name":"burner","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"DailyMintLimitUpdated","inputs":[{"name":"previousLimit","type":"uint256","indexed":false},{"name":"newLimit","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"CustodianProposed","inputs":[{"name":"currentCustodian","type":"address","indexed":true},{"name":"pendingCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"CustodianUpdated","inputs":[{"name":"previousCustodian","type":"address","indexed":true},{"name":"newCustodian","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"EmergencyPauseToggled","inputs":[{"name":"paused","type":"bool","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"mint","inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"burn","inputs":[{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"set_daily_mint_limit","inputs":[{"name":"new_limit","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"propose_owner","inputs":[{"name":"_new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_owner","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"DAY_SECONDS","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DEFAULT_DAILY_MINT_LIMIT","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint8"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"daily_mint_limit","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"mint_window_start","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"minted_in_window","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_initial_owner","type":"address"},{"name":"_initial_recipient","type":"address"},{"name":"_initial_supply","type":"uint256"}],"outputs":[]}]);
|
|
22
|
+
|
|
23
|
+
const WargaSwapV3PoolAbi = Object.freeze([{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"LiquidityAdded","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount0","type":"uint256","indexed":false},{"name":"amount1","type":"uint256","indexed":false},{"name":"liquidity","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"LiquidityRemoved","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"amount0","type":"uint256","indexed":false},{"name":"amount1","type":"uint256","indexed":false},{"name":"liquidity","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Swap","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"tokenIn","type":"address","indexed":true},{"name":"amountIn","type":"uint256","indexed":false},{"name":"amountOut","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Sync","inputs":[{"name":"reserve0","type":"uint256","indexed":false},{"name":"reserve1","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"PoolPauseToggled","inputs":[{"name":"paused","type":"bool","indexed":false}],"anonymous":false,"type":"event"},{"name":"OwnerProposed","inputs":[{"name":"currentOwner","type":"address","indexed":true},{"name":"pendingOwner","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"OwnerTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true},{"name":"newOwner","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"spender","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"lp_balance","inputs":[{"name":"account","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"total_supply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_reserves","inputs":[],"outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_amount_out","inputs":[{"name":"token_in","type":"address"},{"name":"amount_in","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"amount0_desired","type":"uint256"},{"name":"amount1_desired","type":"uint256"},{"name":"amount0_min","type":"uint256"},{"name":"amount1_min","type":"uint256"},{"name":"recipient","type":"address"}],"outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"liquidity","type":"uint256"},{"name":"amount0_min","type":"uint256"},{"name":"amount1_min","type":"uint256"},{"name":"recipient","type":"address"}],"outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"swap","inputs":[{"name":"token_in","type":"address"},{"name":"amount_in","type":"uint256"},{"name":"min_amount_out","type":"uint256"},{"name":"recipient","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"propose_owner","inputs":[{"name":"new_owner","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"accept_owner","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"recover_stray_token","inputs":[{"name":"token","type":"address"},{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"FEE_BPS","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"BPS_DENOM","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"MINIMUM_LIQUIDITY","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"DEAD_ADDRESS","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint8"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"token0","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"token1","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"reserve0","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"reserve1","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pending_owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_token0","type":"address"},{"name":"_token1","type":"address"}],"outputs":[]}]);
|
|
24
|
+
|
|
25
|
+
const QuantumGuardVaultAbi = Object.freeze([{"name":"Deposit","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"WithdrawalCommitted","inputs":[{"name":"commit_hash","type":"bytes32","indexed":true},{"name":"committer","type":"address","indexed":true},{"name":"commit_block","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"QuantumWithdrawalExecuted","inputs":[{"name":"nonce","type":"uint256","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"token","type":"address","indexed":false},{"name":"amount","type":"uint256","indexed":false},{"name":"new_pq_anchor","type":"bytes32","indexed":false}],"anonymous":false,"type":"event"},{"name":"QuantumAnchorRotated","inputs":[{"name":"nonce","type":"uint256","indexed":true},{"name":"new_pq_anchor","type":"bytes32","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"view","type":"function","name":"compute_commit_hash","inputs":[{"name":"secret_preimage","type":"bytes"},{"name":"next_pq_anchor","type":"bytes32"},{"name":"recipient","type":"address"},{"name":"token","type":"address"},{"name":"amount","type":"uint256"},{"name":"committer","type":"address"},{"name":"vault_nonce","type":"uint256"}],"outputs":[{"name":"","type":"bytes32"}]},{"stateMutability":"nonpayable","type":"function","name":"commit_withdrawal","inputs":[{"name":"commit_hash","type":"bytes32"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"reveal_and_execute","inputs":[{"name":"secret_preimage","type":"bytes"},{"name":"next_pq_anchor","type":"bytes32"},{"name":"recipient","type":"address"},{"name":"token","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"rotate_anchor","inputs":[{"name":"secret_preimage","type":"bytes"},{"name":"next_pq_anchor","type":"bytes32"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"toggle_pause","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"current_pq_anchor","inputs":[],"outputs":[{"name":"","type":"bytes32"}]},{"stateMutability":"view","type":"function","name":"min_commit_blocks","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"nonce","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"pending_commits","inputs":[{"name":"arg0","type":"bytes32"}],"outputs":[{"name":"","type":"tuple","components":[{"name":"committer","type":"address"},{"name":"commit_block","type":"uint256"},{"name":"consumed","type":"bool"}]}]},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_initial_pq_anchor","type":"bytes32"},{"name":"_min_commit_blocks","type":"uint256"}],"outputs":[]}]);
|
|
26
|
+
|
|
27
|
+
const ABIS = Object.freeze({
|
|
28
|
+
WargaCoin: WargaCoinAbi,
|
|
29
|
+
WrgVault: WrgVaultAbi,
|
|
30
|
+
MerchantEscrow: MerchantEscrowAbi,
|
|
31
|
+
ValidatorRegistry: ValidatorRegistryAbi,
|
|
32
|
+
MerchantKYCBadgeNFT: MerchantKYCBadgeNFTAbi,
|
|
33
|
+
IDRToken: IDRTokenAbi,
|
|
34
|
+
USDTToken: USDTTokenAbi,
|
|
35
|
+
JPYToken: JPYTokenAbi,
|
|
36
|
+
WargaSwapV3Pool: WargaSwapV3PoolAbi,
|
|
37
|
+
QuantumGuardVault: QuantumGuardVaultAbi,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Warga Network Layer-1 Mainnet configuration (compatible with browsers, ethers v6, & viem).
|
|
43
|
+
*/
|
|
44
|
+
const WARGA_MAINNET = Object.freeze({
|
|
45
|
+
id: 882026,
|
|
46
|
+
chainIdHex: "0xd756a",
|
|
47
|
+
name: "Warga Network Mainnet",
|
|
48
|
+
network: "warga-mainnet",
|
|
49
|
+
nativeCurrency: {
|
|
50
|
+
name: "WargaCoin",
|
|
51
|
+
symbol: "WRG",
|
|
52
|
+
decimals: 18,
|
|
53
|
+
},
|
|
54
|
+
rpcUrls: {
|
|
55
|
+
default: { http: ["https://warganetwork.org/rpc"] },
|
|
56
|
+
public: { http: ["https://warganetwork.org/rpc"] },
|
|
57
|
+
},
|
|
58
|
+
blockExplorers: {
|
|
59
|
+
default: {
|
|
60
|
+
name: "WargaScan",
|
|
61
|
+
url: "https://warganetwork.org/explorer",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
iconUrls: [
|
|
65
|
+
"https://warganetwork.org/wrg-token.png",
|
|
66
|
+
"https://warganetwork.org/wrg-256.png",
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Warga Network Public Testnet configuration.
|
|
72
|
+
*/
|
|
73
|
+
const WARGA_TESTNET = Object.freeze({
|
|
74
|
+
id: 2027,
|
|
75
|
+
chainIdHex: "0x7eb",
|
|
76
|
+
name: "Warga Network Testnet",
|
|
77
|
+
network: "warga-testnet",
|
|
78
|
+
nativeCurrency: {
|
|
79
|
+
name: "Test WargaCoin",
|
|
80
|
+
symbol: "tWRG",
|
|
81
|
+
decimals: 18,
|
|
82
|
+
},
|
|
83
|
+
rpcUrls: {
|
|
84
|
+
default: { http: ["https://warganetwork.org/rpc/testnet"] },
|
|
85
|
+
public: { http: ["https://warganetwork.org/rpc/testnet"] },
|
|
86
|
+
},
|
|
87
|
+
blockExplorers: {
|
|
88
|
+
default: {
|
|
89
|
+
name: "WargaScan Testnet",
|
|
90
|
+
url: "https://warganetwork.org/explorer",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
testnet: true,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Verified live Warga Network L1 (Chain ID 882026) Vyper 0.4.3 contract addresses.
|
|
98
|
+
*/
|
|
99
|
+
const CONTRACTS = Object.freeze({
|
|
100
|
+
WargaCoin: "0x71c7656ec7ab88b098defb751b7401b5f6d8976f",
|
|
101
|
+
WrgVault: "0xb59057f75ab910c587993d84a56da7c5b8442fdc",
|
|
102
|
+
MerchantEscrow: "0x8fab0a68e8f0722c20f1285c30fb97d735e575fe",
|
|
103
|
+
ValidatorRegistry: "0x069ccee0cb1fc3ee67eb0772188b1fdd1103df9e",
|
|
104
|
+
MerchantKYCBadgeNFT: "0x05c622c9664b2876e0dd69fcbb20f0aaef3becc1",
|
|
105
|
+
IDRToken: "0x4044b274536c7e4d371cfe47f9c3dd4d7811b26c",
|
|
106
|
+
USDTToken: "0x99ed79a6435be307d025d61831c8688b2a7ff7cb",
|
|
107
|
+
JPYToken: "0xbae92c718537c5e4eb8b230bc060af4a43450536",
|
|
108
|
+
WargaSwapV3Pool: "0xc6e96ec9b017e3c924e6a0332a89e839dffcbbe7",
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Structured error thrown by WargaClient on RPC / HTTP / timeout failures.
|
|
113
|
+
*/
|
|
114
|
+
class WargaRpcError extends Error {
|
|
115
|
+
constructor(message, { code = null, method = null, status = null } = {}) {
|
|
116
|
+
super(message);
|
|
117
|
+
this.name = "WargaRpcError";
|
|
118
|
+
this.code = code;
|
|
119
|
+
this.method = method;
|
|
120
|
+
this.status = status;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const WEI_PER_WRG = 10n ** 18n;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Format wei (bigint, hex string, or decimal string) into human-readable WRG string.
|
|
128
|
+
*/
|
|
129
|
+
function formatWrg(wei, maxDecimals = 6) {
|
|
130
|
+
const val = typeof wei === "bigint" ? wei : BigInt(wei);
|
|
131
|
+
const negative = val < 0n;
|
|
132
|
+
const abs = negative ? -val : val;
|
|
133
|
+
const whole = abs / WEI_PER_WRG;
|
|
134
|
+
const frac = abs % WEI_PER_WRG;
|
|
135
|
+
if (frac === 0n || maxDecimals <= 0) {
|
|
136
|
+
return `${negative ? "-" : ""}${whole.toString()}`;
|
|
137
|
+
}
|
|
138
|
+
const fracStr = frac.toString().padStart(18, "0").slice(0, maxDecimals).replace(/0+$/, "");
|
|
139
|
+
return fracStr ? `${negative ? "-" : ""}${whole.toString()}.${fracStr}` : `${negative ? "-" : ""}${whole.toString()}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Parse a decimal WRG amount (string or number) into exact wei bigint.
|
|
144
|
+
*/
|
|
145
|
+
function parseWrg(amount) {
|
|
146
|
+
const str = String(amount).trim();
|
|
147
|
+
if (!/^\d+(\.\d+)?$/.test(str)) {
|
|
148
|
+
throw new Error(`Invalid WRG amount: ${amount}`);
|
|
149
|
+
}
|
|
150
|
+
const [wholePart, fracPart = ""] = str.split(".");
|
|
151
|
+
if (fracPart.length > 18) {
|
|
152
|
+
throw new Error(`WRG amount exceeds 18 decimals: ${amount}`);
|
|
153
|
+
}
|
|
154
|
+
return BigInt(wholePart) * WEI_PER_WRG + BigInt(fracPart.padEnd(18, "0"));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Validate a 20-byte hexadecimal EVM address.
|
|
159
|
+
*/
|
|
160
|
+
function isValidAddress(address) {
|
|
161
|
+
return typeof address === "string" && /^0x[0-9a-fA-F]{40}$/.test(address);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Browser-native (WebCrypto SHA-256) helper to compute a QuantumGuardVault.vy anchor
|
|
166
|
+
* from a 32-byte+ secret preimage (string, 0x-hex, or Uint8Array). Zero Node.js imports!
|
|
167
|
+
*/
|
|
168
|
+
async function computeQuantumAnchor(secretPreimage) {
|
|
169
|
+
if (!globalThis.crypto?.subtle) {
|
|
170
|
+
throw new Error("WebCrypto crypto.subtle is unavailable in this runtime.");
|
|
171
|
+
}
|
|
172
|
+
let bytes;
|
|
173
|
+
if (secretPreimage instanceof Uint8Array) {
|
|
174
|
+
bytes = secretPreimage;
|
|
175
|
+
} else if (typeof secretPreimage === "string" && /^0x[0-9a-fA-F]+$/.test(secretPreimage)) {
|
|
176
|
+
const clean = secretPreimage.slice(2);
|
|
177
|
+
if (clean.length % 2 !== 0) throw new Error("Invalid hex preimage length");
|
|
178
|
+
bytes = new Uint8Array(clean.length / 2);
|
|
179
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
180
|
+
bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
bytes = new TextEncoder().encode(String(secretPreimage));
|
|
184
|
+
}
|
|
185
|
+
if (bytes.length < 32) {
|
|
186
|
+
throw new Error("Quantum preimage must be at least 32 bytes (256-bit entropy)");
|
|
187
|
+
}
|
|
188
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
189
|
+
return "0x" + Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Pure offline, zero-dependency transaction drainer / phishing heuristic scanner.
|
|
194
|
+
* Runs 100% locally in browser or Node.js with strict input schema validation (no backend required).
|
|
195
|
+
*/
|
|
196
|
+
function scanTransactionLocal(tx) {
|
|
197
|
+
if (!tx || typeof tx !== "object") {
|
|
198
|
+
throw new Error("Transaction payload must be a non-null object");
|
|
199
|
+
}
|
|
200
|
+
if (tx.to !== undefined && tx.to !== null && !isValidAddress(tx.to)) {
|
|
201
|
+
throw new Error(`Invalid transaction recipient address: ${tx.to}`);
|
|
202
|
+
}
|
|
203
|
+
const rawData = String(tx.data ?? tx.input ?? "0x").trim();
|
|
204
|
+
if (!/^0x[0-9a-fA-F]*$/.test(rawData) || rawData.length % 2 !== 0) {
|
|
205
|
+
throw new Error("Invalid hex calldata in transaction payload");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const data = rawData.toLowerCase();
|
|
209
|
+
const reasons = [];
|
|
210
|
+
let riskLevel = "LOW";
|
|
211
|
+
let drainerDetected = false;
|
|
212
|
+
|
|
213
|
+
// 1. Unlimited ERC-20 approve(address,uint256) selector: 0x095ea7b3
|
|
214
|
+
if (data.startsWith("0x095ea7b3") && data.length >= 138) {
|
|
215
|
+
const amountHex = data.slice(74, 138);
|
|
216
|
+
if (/^f{10,}/i.test(amountHex) || amountHex.includes("ffffffffffffffffffff")) {
|
|
217
|
+
riskLevel = "HIGH";
|
|
218
|
+
drainerDetected = true;
|
|
219
|
+
reasons.push("Unlimited ERC-20 allowance approval detected (approve max uint256)");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 2. Full NFT collection control setApprovalForAll(address,bool) selector: 0xa22cb465
|
|
224
|
+
if (data.startsWith("0xa22cb465") && data.length >= 138) {
|
|
225
|
+
const approvedWord = data.slice(74, 138);
|
|
226
|
+
if (!/^0+$/.test(approvedWord)) {
|
|
227
|
+
riskLevel = "CRITICAL";
|
|
228
|
+
drainerDetected = true;
|
|
229
|
+
reasons.push("Full NFT collection operator approval detected (setApprovalForAll=true)");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 3. Gasless ERC-2612 permit(...) selector: 0xd5054bfd
|
|
234
|
+
if (data.startsWith("0xd5054bfd")) {
|
|
235
|
+
if (riskLevel === "LOW") riskLevel = "MEDIUM";
|
|
236
|
+
reasons.push("ERC-2612 gasless permit signature detected — verify spender & deadline carefully");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 4. Known phishing domain keyword patterns
|
|
240
|
+
const origin = String(tx.origin ?? tx.domain ?? "").toLowerCase();
|
|
241
|
+
for (const kw of ["free-airdrop", "claim-gift", "bonus-wrg-drain", "login-metamask-verify", "recovery-phrase"]) {
|
|
242
|
+
if (origin.includes(kw)) {
|
|
243
|
+
riskLevel = "CRITICAL";
|
|
244
|
+
drainerDetected = true;
|
|
245
|
+
reasons.push(`Suspicious phishing origin pattern detected: ${kw}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
isSafe: !drainerDetected,
|
|
251
|
+
riskLevel,
|
|
252
|
+
drainerDetected,
|
|
253
|
+
reasons,
|
|
254
|
+
source: "local-offline",
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Pure zero-dependency JSON-RPC & Explorer REST client for Warga Network Layer-1.
|
|
260
|
+
* Browser-native (zero Node.js built-ins), works in Chrome/Safari/Firefox, Edge Workers, Deno, Bun, and Node >= 18.
|
|
261
|
+
*/
|
|
262
|
+
class WargaClient {
|
|
263
|
+
constructor(options = {}) {
|
|
264
|
+
const net = options.testnet ? WARGA_TESTNET : WARGA_MAINNET;
|
|
265
|
+
this.rpcUrl = options.rpcUrl || net.rpcUrls.default.http[0];
|
|
266
|
+
this.fallbackRpcUrls = Array.isArray(options.fallbackRpcUrls)
|
|
267
|
+
? options.fallbackRpcUrls.filter(Boolean)
|
|
268
|
+
: options.testnet
|
|
269
|
+
? []
|
|
270
|
+
: ["https://warganetwork.org/rpc2", "https://umkmrumahan.com/rpc"];
|
|
271
|
+
this.apiBaseUrl = (options.apiBaseUrl || "https://warganetwork.org").replace(/\/+$/, "");
|
|
272
|
+
this.timeoutMs = options.timeoutMs || 10000;
|
|
273
|
+
this.retries = options.retries ?? 2;
|
|
274
|
+
this.retryDelayMs = options.retryDelayMs ?? 250;
|
|
275
|
+
this.fetchImpl = options.fetch || globalThis.fetch;
|
|
276
|
+
this._rpcId = 1;
|
|
277
|
+
if (typeof this.fetchImpl !== "function") {
|
|
278
|
+
throw new Error("Fetch API is unavailable. Use a modern browser, Node.js >= 18, or pass options.fetch.");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async _fetchWithRetry(url, init, methodLabel) {
|
|
283
|
+
let lastErr;
|
|
284
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
285
|
+
const controller = new AbortController();
|
|
286
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
287
|
+
try {
|
|
288
|
+
const res = await this.fetchImpl(url, { ...init, signal: controller.signal });
|
|
289
|
+
if (res.ok) return res;
|
|
290
|
+
const transient = res.status === 429 || res.status >= 500;
|
|
291
|
+
lastErr = new WargaRpcError(`HTTP ${res.status} on ${methodLabel}`, { status: res.status, method: methodLabel });
|
|
292
|
+
if (!transient || attempt === this.retries) throw lastErr;
|
|
293
|
+
} catch (err) {
|
|
294
|
+
if (err instanceof WargaRpcError) {
|
|
295
|
+
lastErr = err;
|
|
296
|
+
if (!err.status || (err.status !== 429 && err.status < 500) || attempt === this.retries) throw err;
|
|
297
|
+
} else if (err && err.name === "AbortError") {
|
|
298
|
+
lastErr = new WargaRpcError(`RPC timeout after ${this.timeoutMs}ms on ${methodLabel}`, { code: "ETIMEDOUT", method: methodLabel });
|
|
299
|
+
if (attempt === this.retries) throw lastErr;
|
|
300
|
+
} else {
|
|
301
|
+
lastErr = new WargaRpcError(err?.message || `Network error on ${methodLabel}`, { method: methodLabel });
|
|
302
|
+
if (attempt === this.retries) throw lastErr;
|
|
303
|
+
}
|
|
304
|
+
} finally {
|
|
305
|
+
clearTimeout(timer);
|
|
306
|
+
}
|
|
307
|
+
await new Promise((r) => setTimeout(r, this.retryDelayMs * (attempt + 1)));
|
|
308
|
+
}
|
|
309
|
+
throw lastErr;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async rpc(method, params = []) {
|
|
313
|
+
const endpoints = [this.rpcUrl, ...this.fallbackRpcUrls.filter((u) => u !== this.rpcUrl)];
|
|
314
|
+
const payload = JSON.stringify({
|
|
315
|
+
jsonrpc: "2.0",
|
|
316
|
+
id: this._rpcId++,
|
|
317
|
+
method,
|
|
318
|
+
params,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
let lastErr;
|
|
322
|
+
for (let i = 0; i < endpoints.length; i++) {
|
|
323
|
+
try {
|
|
324
|
+
const res = await this._fetchWithRetry(
|
|
325
|
+
endpoints[i],
|
|
326
|
+
{ method: "POST", headers: { "Content-Type": "application/json" }, body: payload },
|
|
327
|
+
method
|
|
328
|
+
);
|
|
329
|
+
const data = await res.json();
|
|
330
|
+
if (data.error) {
|
|
331
|
+
throw new WargaRpcError(data.error.message || `RPC error ${data.error.code}`, {
|
|
332
|
+
code: data.error.code,
|
|
333
|
+
method,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
return data.result;
|
|
337
|
+
} catch (err) {
|
|
338
|
+
lastErr = err;
|
|
339
|
+
// Deterministic JSON-RPC application error (e.g., -32601, revert) should NOT fail over
|
|
340
|
+
if (err instanceof WargaRpcError && typeof err.code === "number") {
|
|
341
|
+
throw err;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
throw lastErr;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Execute multiple JSON-RPC calls concurrently.
|
|
350
|
+
*/
|
|
351
|
+
async batchRpc(calls) {
|
|
352
|
+
if (!Array.isArray(calls) || calls.length === 0) return [];
|
|
353
|
+
return Promise.all(calls.map((c) => this.rpc(c.method, c.params || [])));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async getTransactionCount(address, blockTag = "pending") {
|
|
357
|
+
if (!isValidAddress(address)) throw new Error(`Invalid EVM address: ${address}`);
|
|
358
|
+
const hex = await this.rpc("eth_getTransactionCount", [address, blockTag]);
|
|
359
|
+
return Number(BigInt(hex));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async estimateGas(txObject) {
|
|
363
|
+
if (!txObject || typeof txObject !== "object") throw new Error("txObject is required");
|
|
364
|
+
const hex = await this.rpc("eth_estimateGas", [txObject]);
|
|
365
|
+
return BigInt(hex);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async sendRawTransaction(signedTxHex) {
|
|
369
|
+
if (typeof signedTxHex !== "string" || !/^0x[0-9a-fA-F]+$/.test(signedTxHex)) {
|
|
370
|
+
throw new Error("signedTxHex must be a valid 0x-prefixed hex string");
|
|
371
|
+
}
|
|
372
|
+
return this.rpc("eth_sendRawTransaction", [signedTxHex]);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async getTransactionReceipt(txHash) {
|
|
376
|
+
if (typeof txHash !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(txHash)) {
|
|
377
|
+
throw new Error(`Invalid transaction hash: ${txHash}`);
|
|
378
|
+
}
|
|
379
|
+
return this.rpc("eth_getTransactionReceipt", [txHash]);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async waitForTransaction(txHash, { timeoutMs = 30000, pollMs = 1500 } = {}) {
|
|
383
|
+
const deadline = Date.now() + timeoutMs;
|
|
384
|
+
while (Date.now() <= deadline) {
|
|
385
|
+
const receipt = await this.getTransactionReceipt(txHash);
|
|
386
|
+
if (receipt) return receipt;
|
|
387
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
388
|
+
}
|
|
389
|
+
throw new WargaRpcError(`Timed out waiting for transaction ${txHash}`, { code: "ETIMEDOUT", method: "eth_getTransactionReceipt" });
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async getLogs(filter = {}) {
|
|
393
|
+
return this.rpc("eth_getLogs", [filter]);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Browser-native event log poller (no WebSocket required). Returns an unsubscribe function.
|
|
398
|
+
*/
|
|
399
|
+
pollLogs(filter, onLogs, { intervalMs = 3000 } = {}) {
|
|
400
|
+
let active = true;
|
|
401
|
+
let lastBlock = null;
|
|
402
|
+
const tick = async () => {
|
|
403
|
+
if (!active) return;
|
|
404
|
+
try {
|
|
405
|
+
const current = await this.getBlockNumber();
|
|
406
|
+
const fromBlock = lastBlock === null ? current : lastBlock + 1;
|
|
407
|
+
if (fromBlock <= current) {
|
|
408
|
+
const logs = await this.getLogs({
|
|
409
|
+
...filter,
|
|
410
|
+
fromBlock: "0x" + fromBlock.toString(16),
|
|
411
|
+
toBlock: "0x" + current.toString(16),
|
|
412
|
+
});
|
|
413
|
+
if (Array.isArray(logs) && logs.length > 0) onLogs(logs);
|
|
414
|
+
lastBlock = current;
|
|
415
|
+
}
|
|
416
|
+
} catch (_) {
|
|
417
|
+
// Non-fatal polling retry on next tick
|
|
418
|
+
}
|
|
419
|
+
if (active) setTimeout(tick, intervalMs);
|
|
420
|
+
};
|
|
421
|
+
tick();
|
|
422
|
+
return () => {
|
|
423
|
+
active = false;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async getChainId() {
|
|
428
|
+
const hex = await this.rpc("eth_chainId");
|
|
429
|
+
return Number(BigInt(hex));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async getBlockNumber() {
|
|
433
|
+
const hex = await this.rpc("eth_blockNumber");
|
|
434
|
+
return Number(BigInt(hex));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
async getGasPrice() {
|
|
438
|
+
const hex = await this.rpc("eth_gasPrice");
|
|
439
|
+
return BigInt(hex);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async getBalance(address, blockTag = "latest") {
|
|
443
|
+
if (!isValidAddress(address)) {
|
|
444
|
+
throw new Error(`Invalid EVM address: ${address}`);
|
|
445
|
+
}
|
|
446
|
+
const hex = await this.rpc("eth_getBalance", [address, blockTag]);
|
|
447
|
+
const wei = BigInt(hex);
|
|
448
|
+
return {
|
|
449
|
+
address,
|
|
450
|
+
wei,
|
|
451
|
+
wrg: formatWrg(wei),
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
async lookupWallet(query) {
|
|
456
|
+
const res = await this.fetchImpl(
|
|
457
|
+
`${this.apiBaseUrl}/api/warganetwork/explorer/lookup?q=${encodeURIComponent(query)}`
|
|
458
|
+
);
|
|
459
|
+
if (!res.ok) {
|
|
460
|
+
throw new WargaRpcError(`Explorer lookup HTTP ${res.status}`, { status: res.status });
|
|
461
|
+
}
|
|
462
|
+
return res.json();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async getPqcStatus() {
|
|
466
|
+
const res = await this.fetchImpl(`${this.apiBaseUrl}/api/pqc/status`);
|
|
467
|
+
if (!res.ok) {
|
|
468
|
+
throw new WargaRpcError(`PQC status HTTP ${res.status}`, { status: res.status });
|
|
469
|
+
}
|
|
470
|
+
return res.json();
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async getPqcPubKey() {
|
|
474
|
+
const res = await this.fetchImpl(`${this.apiBaseUrl}/api/pqc/pubkey`);
|
|
475
|
+
if (!res.ok) {
|
|
476
|
+
throw new WargaRpcError(`PQC pubkey HTTP ${res.status}`, { status: res.status });
|
|
477
|
+
}
|
|
478
|
+
return res.json();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async getPqcAttestation() {
|
|
482
|
+
const res = await this.fetchImpl(`${this.apiBaseUrl}/api/pqc/attestation`);
|
|
483
|
+
if (!res.ok) {
|
|
484
|
+
throw new WargaRpcError(`PQC attestation HTTP ${res.status}`, { status: res.status });
|
|
485
|
+
}
|
|
486
|
+
return res.json();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
async verifyMLDSA65(message, signatureHex, publicKeyHex = null) {
|
|
490
|
+
const res = await this.fetchImpl(`${this.apiBaseUrl}/api/pqc/verify`, {
|
|
491
|
+
method: "POST",
|
|
492
|
+
headers: { "Content-Type": "application/json" },
|
|
493
|
+
body: JSON.stringify({
|
|
494
|
+
message,
|
|
495
|
+
signature_hex: signatureHex,
|
|
496
|
+
...(publicKeyHex ? { public_key_hex: publicKeyHex } : {}),
|
|
497
|
+
}),
|
|
498
|
+
});
|
|
499
|
+
if (!res.ok) {
|
|
500
|
+
throw new WargaRpcError(`ML-DSA-65 verify HTTP ${res.status}`, { status: res.status });
|
|
501
|
+
}
|
|
502
|
+
return res.json();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async scanTransaction(txPayload, { localOnly = false } = {}) {
|
|
506
|
+
// Always validate schema & run deterministic offline scanner first (zero external trust!)
|
|
507
|
+
const localAnalysis = scanTransactionLocal(txPayload);
|
|
508
|
+
if (localOnly) {
|
|
509
|
+
return { success: true, analysis: localAnalysis };
|
|
510
|
+
}
|
|
511
|
+
try {
|
|
512
|
+
const res = await this.fetchImpl(`${this.apiBaseUrl}/api/pqc/scan-tx`, {
|
|
513
|
+
method: "POST",
|
|
514
|
+
headers: { "Content-Type": "application/json" },
|
|
515
|
+
body: JSON.stringify({
|
|
516
|
+
to: txPayload.to,
|
|
517
|
+
data: txPayload.data ?? txPayload.input ?? "0x",
|
|
518
|
+
...(txPayload.origin ? { origin: txPayload.origin } : {}),
|
|
519
|
+
}),
|
|
520
|
+
});
|
|
521
|
+
if (!res.ok) return { success: true, analysis: localAnalysis };
|
|
522
|
+
const remote = await res.json();
|
|
523
|
+
return {
|
|
524
|
+
success: true,
|
|
525
|
+
analysis: remote?.analysis?.drainerDetected ? remote.analysis : localAnalysis,
|
|
526
|
+
remote: remote?.analysis || null,
|
|
527
|
+
};
|
|
528
|
+
} catch (_) {
|
|
529
|
+
return { success: true, analysis: localAnalysis };
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* High-level helper wrapper for MerchantEscrow.vy v2 (timeout, dispute, release, expiry refund).
|
|
538
|
+
* Accepts any ethers v6 Contract instance (or custom contract adapter) — zero hard dependencies!
|
|
539
|
+
*/
|
|
540
|
+
class WargaEscrow {
|
|
541
|
+
constructor(contract) {
|
|
542
|
+
if (!contract) {
|
|
543
|
+
throw new Error("Pass an initialized MerchantEscrow contract instance (e.g. new ethers.Contract(CONTRACTS.MerchantEscrow, ABIS.MerchantEscrow, signer)).");
|
|
544
|
+
}
|
|
545
|
+
this.contract = contract;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
static create(ethersContractCtor, signerOrProvider, address = CONTRACTS.MerchantEscrow) {
|
|
549
|
+
return new WargaEscrow(new ethersContractCtor(address, ABIS.MerchantEscrow, signerOrProvider));
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async lockOrder(orderId, merchant, amountWei) {
|
|
553
|
+
return this.contract.lock_order(orderId, merchant, amountWei);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async lockOrderWithTimeout(orderId, merchant, amountWei, timeoutSeconds) {
|
|
557
|
+
return this.contract.lock_order_with_timeout(orderId, merchant, amountWei, timeoutSeconds);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
async openDispute(orderId, reason) {
|
|
561
|
+
return this.contract.open_dispute(orderId, reason);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
async releaseEscrow(orderId) {
|
|
565
|
+
return this.contract.release_escrow(orderId);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
async refundEscrow(orderId, reason) {
|
|
569
|
+
return this.contract.refund_escrow(orderId, reason);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
async claimExpiredOrder(orderId) {
|
|
573
|
+
return this.contract.claim_expired_order(orderId);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
async resolveDispute(orderId, releaseToMerchant, resolutionNote) {
|
|
577
|
+
return this.contract.resolve_dispute(orderId, releaseToMerchant, resolutionNote);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
async getOrder(orderId) {
|
|
581
|
+
return this.contract.orders(orderId);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* High-level helper wrapper for WargaSwapV3Pool.vy v2 (constant-product x*y=k AMM + slippage math).
|
|
587
|
+
*/
|
|
588
|
+
class WargaPool {
|
|
589
|
+
constructor(contract) {
|
|
590
|
+
if (!contract) {
|
|
591
|
+
throw new Error("Pass an initialized WargaSwapV3Pool contract instance.");
|
|
592
|
+
}
|
|
593
|
+
this.contract = contract;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
static create(ethersContractCtor, signerOrProvider, address = CONTRACTS.WargaSwapV3Pool) {
|
|
597
|
+
return new WargaPool(new ethersContractCtor(address, ABIS.WargaSwapV3Pool, signerOrProvider));
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
static computeMinOut(quotedOutWei, slippageBps = 50) {
|
|
601
|
+
const q = BigInt(quotedOutWei);
|
|
602
|
+
if (slippageBps < 0 || slippageBps >= 10000) {
|
|
603
|
+
throw new Error(`Invalid slippageBps: ${slippageBps}`);
|
|
604
|
+
}
|
|
605
|
+
return (q * BigInt(10000 - slippageBps)) / 10000n;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
async getReserves() {
|
|
609
|
+
return this.contract.get_reserves();
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
async quoteSwap(tokenIn, amountInWei, slippageBps = 50) {
|
|
613
|
+
const amountOut = await this.contract.get_amount_out(tokenIn, amountInWei);
|
|
614
|
+
return {
|
|
615
|
+
amountOut: BigInt(amountOut),
|
|
616
|
+
minAmountOut: WargaPool.computeMinOut(amountOut, slippageBps),
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
async swap(tokenIn, amountInWei, minAmountOutWei, recipient) {
|
|
621
|
+
return this.contract.swap(tokenIn, amountInWei, minAmountOutWei, recipient);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* High-level helper wrapper for MerchantKYCBadgeNFT.vy v2 (ERC-5192 Soulbound e-KYC NFT).
|
|
627
|
+
*/
|
|
628
|
+
class WargaKycBadge {
|
|
629
|
+
constructor(contract) {
|
|
630
|
+
if (!contract) {
|
|
631
|
+
throw new Error("Pass an initialized MerchantKYCBadgeNFT contract instance.");
|
|
632
|
+
}
|
|
633
|
+
this.contract = contract;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
static create(ethersContractCtor, signerOrProvider, address = CONTRACTS.MerchantKYCBadgeNFT) {
|
|
637
|
+
return new WargaKycBadge(new ethersContractCtor(address, ABIS.MerchantKYCBadgeNFT, signerOrProvider));
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
async verifyBadge(tokenId) {
|
|
641
|
+
const [isErc5192, isLocked, owner, uri] = await Promise.all([
|
|
642
|
+
this.contract.supportsInterface("0xb45a3c0e"),
|
|
643
|
+
this.contract.locked(tokenId),
|
|
644
|
+
this.contract.ownerOf(tokenId),
|
|
645
|
+
this.contract.tokenURI(tokenId),
|
|
646
|
+
]);
|
|
647
|
+
return { isErc5192, isLocked, owner, uri };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
async mintBadge(recipient, storeId, storeName, kycHash, metadataUri) {
|
|
651
|
+
return this.contract.mintBadge(recipient, storeId, storeName, kycHash, metadataUri);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
async revokeBadge(tokenId) {
|
|
655
|
+
return this.contract.revokeBadge(tokenId);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
module.exports = { WARGA_MAINNET, WARGA_TESTNET, CONTRACTS, ABIS, WargaCoinAbi, WrgVaultAbi, MerchantEscrowAbi, ValidatorRegistryAbi, MerchantKYCBadgeNFTAbi, IDRTokenAbi, USDTTokenAbi, JPYTokenAbi, WargaSwapV3PoolAbi, QuantumGuardVaultAbi, WargaClient, WargaRpcError, WargaEscrow, WargaPool, WargaKycBadge, formatWrg, parseWrg, isValidAddress, computeQuantumAnchor, scanTransactionLocal };
|