├── docs ├── .nojekyll ├── start.sh ├── media │ └── logo.png ├── coins │ └── bitcoin │ │ └── images │ │ ├── rune_batch_mint.png │ │ └── rune_serial_mint.png └── _coverpage.md ├── jest.setup.js ├── .npmrc ├── bu-packages ├── coin-base │ ├── src │ │ ├── basic │ │ │ └── index.ts │ │ ├── math │ │ │ └── index.ts │ │ ├── base │ │ │ ├── base64.ts │ │ │ ├── base58.ts │ │ │ ├── hmac.ts │ │ │ ├── base58Check.ts │ │ │ ├── bech32.ts │ │ │ ├── helper.ts │ │ │ ├── utf8.ts │ │ │ ├── bignumber-plus.ts │ │ │ ├── precondtion.ts │ │ │ └── hex.ts │ │ ├── abi │ │ │ └── index.ts │ │ └── index.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── patches │ │ └── @protobufjs+inquire+1.1.0.patch ├── coin-xrp │ ├── src │ │ ├── index.ts │ │ └── const.ts │ ├── jest.config.js │ ├── CHANGELOG.md │ └── tsconfig.json ├── coin-aptos │ ├── src │ │ ├── v2 │ │ │ ├── core │ │ │ │ ├── account │ │ │ │ │ ├── index.ts │ │ │ │ │ └── utils │ │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ └── crypto │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── privateKey.ts │ │ │ │ │ └── utils.ts │ │ │ ├── utils │ │ │ │ ├── index.ts │ │ │ │ ├── apiEndpoints.ts │ │ │ │ └── normalizeBundle.ts │ │ │ ├── types │ │ │ │ ├── abstraction.ts │ │ │ │ └── codegen.yaml │ │ │ ├── account │ │ │ │ └── index.ts │ │ │ ├── transactions │ │ │ │ ├── authenticator │ │ │ │ │ └── index.ts │ │ │ │ ├── transactionBuilder │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ └── instances │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── chainId.ts │ │ │ │ │ └── identifier.ts │ │ │ ├── api │ │ │ │ ├── index.ts │ │ │ │ └── aptosConfig.ts │ │ │ ├── version.ts │ │ │ ├── index.ts │ │ │ └── bcs │ │ │ │ ├── index.ts │ │ │ │ └── consts.ts │ │ ├── utils │ │ │ ├── index.ts │ │ │ └── misc.ts │ │ ├── generated │ │ │ ├── index.ts │ │ │ └── models │ │ │ │ └── HexEncodedBytes.ts │ │ ├── index.ts │ │ └── transaction_builder │ │ │ ├── bcs │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── consts.ts │ │ │ ├── index.ts │ │ │ └── aptos_types │ │ │ ├── index.ts │ │ │ └── identifier.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-sui │ ├── src │ │ ├── pkg-version.ts │ │ ├── framework │ │ │ └── index.ts │ │ ├── builder │ │ │ ├── index.ts │ │ │ └── utils.ts │ │ ├── utils │ │ │ ├── properties.ts │ │ │ ├── format.ts │ │ │ └── intent.ts │ │ ├── signers │ │ │ ├── types.ts │ │ │ └── signer.ts │ │ ├── types │ │ │ ├── index.ts │ │ │ ├── option.ts │ │ │ └── faucet.ts │ │ ├── bcs │ │ │ └── hex.ts │ │ └── cryptography │ │ │ ├── hash.ts │ │ │ └── keypair.ts │ ├── jest.config.js │ └── tsconfig.json ├── coin-kaia │ ├── src │ │ ├── index.ts │ │ ├── v6 │ │ │ ├── types.ts │ │ │ └── index.ts │ │ └── api.ts │ ├── babel.config.js │ ├── tsconfig.json │ ├── CHANGELOG.md │ └── jest.config.js ├── coin-cosmos │ ├── src │ │ └── lib │ │ │ ├── kava │ │ │ ├── index.ts │ │ │ ├── auction │ │ │ │ └── v1beta1 │ │ │ │ │ └── tx.amino.ts │ │ │ ├── aminotypes.ts │ │ │ ├── swap │ │ │ │ └── v1beta1 │ │ │ │ │ └── tx.amino.ts │ │ │ └── hard │ │ │ │ └── v1beta1 │ │ │ │ └── tx.amino.ts │ │ │ ├── osmosis │ │ │ ├── index.ts │ │ │ └── aminotypes.ts │ │ │ ├── cosmwasm │ │ │ └── index.ts │ │ │ └── types │ │ │ ├── gogoproto │ │ │ └── gogo.ts │ │ │ └── google │ │ │ └── api │ │ │ └── annotations.ts │ ├── jest.config.js │ └── tsconfig.json ├── coin-solana │ ├── src │ │ ├── lib │ │ │ ├── metaplex │ │ │ │ ├── plugins │ │ │ │ │ └── nftModule │ │ │ │ │ │ └── models │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ └── Metadata.ts │ │ │ │ ├── mpl-token-metadata │ │ │ │ │ ├── instructions │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── types │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── LeafInfo.ts │ │ │ │ │ │ ├── SeedsVec.ts │ │ │ │ │ │ ├── AuthorizationData.ts │ │ │ │ │ │ ├── Payload.ts │ │ │ │ │ │ ├── AuthorityType.ts │ │ │ │ │ │ ├── TokenStandard.ts │ │ │ │ │ │ └── TokenDelegateRole.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── utils │ │ │ │ │ ├── index.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── types │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── Pda.ts │ │ │ │ │ ├── PublicKey.ts │ │ │ │ │ ├── BigNumber.ts │ │ │ │ │ └── Program.ts │ │ │ │ └── index.ts │ │ │ ├── buffer-layout │ │ │ │ ├── index.ts │ │ │ │ └── utils │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── base.ts │ │ │ │ │ ├── native.ts │ │ │ │ │ └── web3.ts │ │ │ ├── index.ts │ │ │ ├── web3 │ │ │ │ ├── programs │ │ │ │ │ └── index.ts │ │ │ │ ├── transaction │ │ │ │ │ ├── index.ts │ │ │ │ │ └── constants.ts │ │ │ │ ├── blockhash.ts │ │ │ │ ├── utils │ │ │ │ │ ├── assert.ts │ │ │ │ │ ├── to-buffer.ts │ │ │ │ │ └── shortvec-encoding.ts │ │ │ │ ├── index.ts │ │ │ │ └── fee-calculator.ts │ │ │ └── spl │ │ │ │ └── instructions │ │ │ │ ├── index.ts │ │ │ │ └── types.ts │ │ └── index.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-starknet │ ├── src │ │ ├── lib │ │ │ ├── signer │ │ │ │ └── index.ts │ │ │ ├── account │ │ │ │ └── index.ts │ │ │ ├── types │ │ │ │ ├── api │ │ │ │ │ ├── index.ts │ │ │ │ │ └── jsonrpc │ │ │ │ │ │ └── index.ts │ │ │ │ ├── starknet-types-08 │ │ │ │ │ ├── snip-29 │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── wallet-api │ │ │ │ │ │ ├── constants.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── StarknetWindowObject.ts │ │ │ │ │ │ ├── events.ts │ │ │ │ │ │ └── errors.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── api │ │ │ │ │ │ └── index.ts │ │ │ │ ├── cairoEnum.ts │ │ │ │ ├── typedData.ts │ │ │ │ ├── helpers │ │ │ │ │ ├── valuesType.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ └── lib │ │ │ │ │ └── contract │ │ │ │ │ ├── index.ts │ │ │ │ │ └── legacy.ts │ │ │ ├── utils │ │ │ │ ├── ec.ts │ │ │ │ ├── calldata │ │ │ │ │ ├── enum │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── parser │ │ │ │ │ │ ├── interface.ts │ │ │ │ │ │ └── parser-0-1.1.0.ts │ │ │ │ ├── hash │ │ │ │ │ └── index.ts │ │ │ │ ├── json │ │ │ │ │ ├── numberParsers.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── connect │ │ │ │ │ ├── fetch.ts │ │ │ │ │ └── ws.ts │ │ │ │ └── assert.ts │ │ │ └── provider │ │ │ │ └── types │ │ │ │ ├── index.type.ts │ │ │ │ └── configuration.type.ts │ │ ├── constants.ts │ │ └── index.ts │ ├── jest.config.js │ ├── CHANGELOG.md │ └── tsconfig.json ├── coin-stellar │ ├── src │ │ ├── lib │ │ │ ├── xdr.js │ │ │ ├── jsxdr.js │ │ │ ├── hashing.js │ │ │ ├── util │ │ │ │ ├── bignumber.js │ │ │ │ ├── util.js │ │ │ │ └── checksum.js │ │ │ ├── operations │ │ │ │ ├── inflation.js │ │ │ │ ├── end_sponsoring_future_reserves.js │ │ │ │ └── account_merge.js │ │ │ ├── numbers │ │ │ │ ├── int128.js │ │ │ │ ├── int256.js │ │ │ │ ├── uint128.js │ │ │ │ └── uint256.js │ │ │ └── network.js │ │ ├── index.ts │ │ ├── utils.ts │ │ └── PIWallet.ts │ ├── babel.config.json │ ├── tsconfig.json │ ├── jest.config.js │ └── CHANGELOG.md ├── coin-bitcoin │ ├── src │ │ ├── cat20 │ │ │ ├── index.ts │ │ │ ├── transaction │ │ │ │ ├── index.ts │ │ │ │ └── merge.ts │ │ │ ├── utils │ │ │ │ ├── index.ts │ │ │ │ └── utxo.ts │ │ │ └── common │ │ │ │ ├── index.ts │ │ │ │ ├── minterFinder.ts │ │ │ │ ├── btc.ts │ │ │ │ ├── contract.ts │ │ │ │ ├── cat20Enum.ts │ │ │ │ ├── metadata.ts │ │ │ │ └── common.ts │ │ ├── wallet │ │ │ ├── index.ts │ │ │ └── CatWallet.ts │ │ ├── bitcoinjs-lib │ │ │ ├── bip174 │ │ │ │ ├── parser │ │ │ │ │ └── index.ts │ │ │ │ └── converter │ │ │ │ │ ├── global │ │ │ │ │ └── unsignedTx.ts │ │ │ │ │ └── shared │ │ │ │ │ └── checkPubkey.ts │ │ │ ├── varuint.d.ts │ │ │ ├── index.ts │ │ │ └── payments │ │ │ │ └── lazy.ts │ │ ├── common.ts │ │ ├── index.ts │ │ └── bitcoincash │ │ │ └── validation.ts │ ├── doc │ │ └── images │ │ │ ├── rune_batch_mint.png │ │ │ └── rune_serial_mint.png │ ├── jest.config.js │ ├── tsconfig.json │ └── patches │ │ ├── js-sha256+0.9.0.patch │ │ └── scrypt-ts+1.4.3.patch ├── coin-kaspa │ ├── src │ │ ├── index.ts │ │ └── lib │ │ │ └── validation.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-ethereum │ ├── src │ │ ├── index.ts │ │ └── lib │ │ │ └── sdk │ │ │ ├── index.ts │ │ │ ├── ethereumjs-util │ │ │ ├── externals.d.ts │ │ │ └── index.ts │ │ │ └── ethereumjs-tx │ │ │ └── index.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-cardano │ ├── src │ │ └── index.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-nostrassets │ ├── src │ │ ├── index.ts │ │ ├── keys.ts │ │ └── keys.test.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-ton │ ├── src │ │ ├── index.ts │ │ ├── lib │ │ │ ├── ton-core │ │ │ │ ├── dict │ │ │ │ │ ├── utils │ │ │ │ │ │ ├── readUnaryLength.ts │ │ │ │ │ │ └── findCommonPrefix.ts │ │ │ │ │ └── generateMerkleUpdate.ts │ │ │ │ ├── utils │ │ │ │ │ ├── maybe.ts │ │ │ │ │ ├── crc16.ts │ │ │ │ │ ├── bitsForNumber.ts │ │ │ │ │ └── crc32c.ts │ │ │ │ ├── boc │ │ │ │ │ ├── Writable.ts │ │ │ │ │ ├── CellType.ts │ │ │ │ │ └── cell │ │ │ │ │ │ └── exoticLibrary.ts │ │ │ │ ├── types │ │ │ │ │ ├── SendMode.ts │ │ │ │ │ └── TickTock.ts │ │ │ │ ├── contract │ │ │ │ │ ├── ContractState.ts │ │ │ │ │ ├── Contract.ts │ │ │ │ │ ├── Sender.ts │ │ │ │ │ └── ComputeError.ts │ │ │ │ └── address │ │ │ │ │ ├── contractAddress.ts │ │ │ │ │ └── ExternalAddress.ts │ │ │ ├── ton-crypto-primitives │ │ │ │ ├── node │ │ │ │ │ ├── sha256.ts │ │ │ │ │ ├── sha512.ts │ │ │ │ │ ├── getSecureRandom.ts │ │ │ │ │ ├── hmac_sha512.ts │ │ │ │ │ └── pbkdf2_sha512.ts │ │ │ │ └── node.ts │ │ │ └── ton-crypto │ │ │ │ ├── primitives │ │ │ │ └── pbkdf2_sha512.ts │ │ │ │ └── index.ts │ │ ├── ton │ │ │ ├── index.ts │ │ │ └── utils │ │ │ │ └── maybe.ts │ │ └── api │ │ │ └── index.ts │ ├── jest.config.js │ ├── tsconfig.json │ └── CHANGELOG.md ├── crypto-lib │ ├── src │ │ ├── signutil │ │ │ ├── index.ts │ │ │ └── schnorr │ │ │ │ ├── index.ts │ │ │ │ └── _shortw_utils.ts │ │ ├── lib │ │ │ └── base │ │ │ │ ├── README.md │ │ │ │ ├── base58.ts │ │ │ │ ├── hmac.ts │ │ │ │ ├── helper.ts │ │ │ │ └── hex.ts │ │ ├── bip32 │ │ │ ├── index.ts │ │ │ └── bip32_v2.ts │ │ ├── elliptic │ │ │ ├── curve │ │ │ │ └── index.js │ │ │ └── index.ts │ │ └── index.ts │ ├── jest.config.js │ └── tsconfig.json ├── coin-eos │ ├── jest.config.js │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-near │ ├── jest.config.js │ ├── src │ │ ├── serialize.ts │ │ ├── enums.ts │ │ └── nearlib.ts │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-stacks │ ├── jest.config.js │ ├── src │ │ ├── network │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── encryption │ │ │ ├── hashRipemd160.ts │ │ │ ├── index.ts │ │ │ └── cryptoRandom.ts │ │ ├── base-x │ │ │ └── index.d.ts │ │ ├── common │ │ │ ├── index.ts │ │ │ ├── config.ts │ │ │ ├── constants.ts │ │ │ └── keys.ts │ │ ├── c32check │ │ │ └── index.ts │ │ └── transactions │ │ │ └── clarity │ │ │ └── constants.ts │ ├── tsconfig.json │ └── CHANGELOG.md ├── coin-tron │ ├── jest.config.js │ ├── src │ │ └── lib │ │ │ └── protobuf │ │ │ ├── attribution.md │ │ │ └── Discover.proto │ ├── tsconfig.json │ └── CHANGELOG.md └── coin-zkspace │ ├── jest.config.js │ ├── src │ └── index.ts │ └── tsconfig.json ├── lerna.json ├── .gitignore ├── SECURITY.md ├── examples ├── src │ ├── index.tsx │ ├── components │ │ ├── SignedOutput.tsx │ │ ├── toast.tsx │ │ └── AddressOutput.tsx │ ├── pages │ │ ├── Ton.tsx │ │ └── Btc.tsx │ └── App.tsx ├── .gitignore └── tsconfig.json ├── .prettierrc └── tsconfig.json /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/start.sh: -------------------------------------------------------------------------------- 1 | docsify serve -------------------------------------------------------------------------------- /jest.setup.js: -------------------------------------------------------------------------------- 1 | jest.setTimeout(30000); 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmmirror.com 2 | legacy-peer-deps=true -------------------------------------------------------------------------------- /bu-packages/coin-base/src/basic/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./typeUtils" 2 | -------------------------------------------------------------------------------- /bu-packages/coin-xrp/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export * from "./XrpWallet" 3 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/account/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./utils"; 2 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/pkg-version.ts: -------------------------------------------------------------------------------- 1 | export const pkgVersion = '0.29.1'; 2 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/account/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./address"; 2 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./api" 2 | export * from "./KaiaWallet" -------------------------------------------------------------------------------- /docs/media/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okx/js-wallet-sdk/HEAD/docs/media/logo.png -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./misc"; 2 | export * from "./memoize_decorator"; -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/kava/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./registry" 2 | export * from "./aminotypes" -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/osmosis/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./registry" 2 | export * from "./aminotypes" -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/plugins/nftModule/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Metadata'; 2 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/generated/index.ts: -------------------------------------------------------------------------------- 1 | export type { HexEncodedBytes } from './models/HexEncodedBytes'; -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/buffer-layout/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./layout" 2 | export * from "./utils" 3 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/instructions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Transfer'; 2 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/signer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interface'; 2 | export * from './default'; 3 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/cosmwasm/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./wasm/v1/tx.amino" 2 | export * from "./registry" -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/account/index.ts: -------------------------------------------------------------------------------- 1 | export * from './default'; 2 | export * from './interface'; 3 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/xdr.js: -------------------------------------------------------------------------------- 1 | import xdr from './generated/curr_generated'; 2 | 3 | export default xdr; 4 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/index.ts: -------------------------------------------------------------------------------- 1 | export * as api from "./api" 2 | export * from "./lib" 3 | export * from "./SolWallet" 4 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './TransactionBuilder'; 2 | export * from './types'; 3 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/index.ts: -------------------------------------------------------------------------------- 1 | export * from './common' 2 | export * from './transaction' 3 | export * from './utils' 4 | -------------------------------------------------------------------------------- /bu-packages/coin-kaspa/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./KaspaWallet"; 2 | export * from "./address"; 3 | export * from "./transaction"; 4 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/api/index.ts: -------------------------------------------------------------------------------- 1 | export * as JRPC from './jsonrpc'; 2 | export * from '../../provider/types/spec.type'; 3 | -------------------------------------------------------------------------------- /docs/coins/bitcoin/images/rune_batch_mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okx/js-wallet-sdk/HEAD/docs/coins/bitcoin/images/rune_batch_mint.png -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/lerna/schemas/lerna-schema.json", 3 | "version": "independent", 4 | "npmClient": "npm" 5 | } -------------------------------------------------------------------------------- /bu-packages/coin-base/src/math/index.ts: -------------------------------------------------------------------------------- 1 | export { Decimal } from "./decimal"; 2 | export { Int53, Uint32, Uint53, Uint64 } from "./integers"; 3 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/transaction/index.ts: -------------------------------------------------------------------------------- 1 | export * from './functions' 2 | export * from './merge' 3 | export * from './transfer' 4 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/ec.ts: -------------------------------------------------------------------------------- 1 | import {signUtil} from "@okxweb3/crypto-lib" 2 | export const starkCurve = signUtil.schnorr.stark; 3 | -------------------------------------------------------------------------------- /docs/coins/bitcoin/images/rune_serial_mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okx/js-wallet-sdk/HEAD/docs/coins/bitcoin/images/rune_serial_mint.png -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/index.ts: -------------------------------------------------------------------------------- 1 | export * as spl from "./spl" 2 | export * as web3 from "./web3" 3 | export * as metaplex from "./metaplex" 4 | -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./api" 2 | export * from "./message" 3 | export * from "./lib/sdk" 4 | export * from "./EthWallet" 5 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/doc/images/rune_batch_mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okx/js-wallet-sdk/HEAD/bu-packages/coin-bitcoin/doc/images/rune_batch_mint.png -------------------------------------------------------------------------------- /bu-packages/coin-cardano/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./account"; 2 | export * from "./AdaWallet"; 3 | export * from "./transaction"; 4 | export * from "./message" -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/src/lib/sdk/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ethereumjs-util" 2 | export * from "./ethereumjs-tx" 3 | export * as sigUtil from "./eth-sig-util" -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/framework/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from './framework'; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/doc/images/rune_serial_mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okx/js-wallet-sdk/HEAD/bu-packages/coin-bitcoin/doc/images/rune_serial_mint.png -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/programs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './address-lookup-table'; 2 | export * from './system'; 3 | export * from './compute-budget'; 4 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/calldata/enum/index.ts: -------------------------------------------------------------------------------- 1 | export * from './CairoCustomEnum'; 2 | export * from './CairoOption'; 3 | export * from './CairoResult'; 4 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./apiEndpoints"; 2 | export * from "./const"; 3 | export * from "./normalizeBundle"; 4 | export * from "./helpers"; -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./NostrAssetsWallet"; 2 | export * from "./nostrassets"; 3 | export * from "./keys"; 4 | export * from "./event"; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/jsxdr.js: -------------------------------------------------------------------------------- 1 | import { XdrWriter, XdrReader } from '@stellar/js-xdr'; 2 | 3 | const cereal = { XdrWriter, XdrReader }; 4 | export default cereal; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/types/abstraction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The variant for the AbstractionAuthData enum. 3 | */ 4 | export enum AbstractionAuthDataVariant { 5 | V1 = 0, 6 | } 7 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export * from "./lib" 4 | export * from "./StellarWallet" 5 | export * from "./PIWallet" 6 | 7 | 8 | export default module.exports; 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | .vscode 3 | build 4 | dist 5 | node_modules 6 | coverage 7 | *.log 8 | .env.local 9 | .DS_Store 10 | *.tsbuildinfo 11 | *.tgz 12 | .eslintcache 13 | yarn.lock 14 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/account/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Ed25519Account"; 2 | export * from "./Account"; 3 | export * from "./SingleKeyAccount"; 4 | export * from "./MultiKeyAccount"; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | ['@babel/preset-env', {targets: {node: 'current'}}], 4 | '@babel/preset-typescript', 5 | ], 6 | }; -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/snip-29/index.ts: -------------------------------------------------------------------------------- 1 | export * from './methods'; 2 | export * from './errors'; 3 | export * from './components'; 4 | export * from './nonspec'; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./TonWallet"; 2 | export * from "./api/address"; 3 | export * from "./api/transaction"; 4 | export * from "./lib/ton-core"; 5 | export * from "./ton"; 6 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/signutil/index.ts: -------------------------------------------------------------------------------- 1 | export * as secp256k1 from "./secp256k1" 2 | export * as ed25519 from "./ed25519" 3 | export * as p256 from "./p256" 4 | export * as schnorr from "./schnorr" -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './eckey'; 2 | export * from './paramsUtils'; 3 | export * from './prevTx'; 4 | export * from './utils'; 5 | export * from './utxo'; 6 | 7 | -------------------------------------------------------------------------------- /bu-packages/coin-eos/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-eos', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-eos/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./api" 2 | export * from "./txBuilder" 3 | export * from "./types" 4 | export * from "./action" 5 | export * from "./numeric" 6 | export * from "./EosWallet" 7 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-sui', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-ton', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'crypto-lib', 5 | }; -------------------------------------------------------------------------------- /bu-packages/coin-aptos/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-aptos', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/authenticator/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./account"; 5 | export * from "./transaction"; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-base/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-base', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-cosmos', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-kaspa/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-kaspa', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-near/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-near', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-solana', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-stacks', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-tron/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-tron', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-bitcoin', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-cardano/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-cardano', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-ethereum', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-starknet', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-xrp/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-xrp', 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /bu-packages/coin-zkspace/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-zkspace', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-nostrassets', 5 | }; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/transaction/index.ts: -------------------------------------------------------------------------------- 1 | export * from './constants'; 2 | export * from './expiry-custom-errors'; 3 | export * from './legacy'; 4 | export * from './message'; 5 | export * from './versioned'; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/hashing.js: -------------------------------------------------------------------------------- 1 | import { sha256 } from 'sha.js'; 2 | 3 | export function hash(data) { 4 | const hasher = new sha256(); 5 | hasher.update(data, 'utf8'); 6 | return hasher.digest(); 7 | } 8 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/api/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./aptosConfig"; 5 | export * from "./transaction"; 6 | export * from "./fungibleAsset"; 7 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/cairoEnum.ts: -------------------------------------------------------------------------------- 1 | import { CairoCustomEnum, CairoOption, CairoResult } from '../utils/calldata/enum'; 2 | 3 | export type CairoEnum = CairoCustomEnum | CairoOption | CairoResult; 4 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/buffer-layout/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base'; 2 | export * from './bigint'; 3 | export * from './decimal'; 4 | export * from './native'; 5 | export * from './web3'; 6 | export * from '../layout'; 7 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/network/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | export * from './network'; -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/wallet-api/constants.ts: -------------------------------------------------------------------------------- 1 | export const Permission = { 2 | ACCOUNTS: 'accounts', 3 | } as const; 4 | 5 | export type Permission = (typeof Permission)[keyof typeof Permission]; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/hash/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Hashes Exports 3 | */ 4 | export * from './selector'; // Preserve legacy export structure 5 | 6 | export * from './transactionHash'; 7 | export * from './classHash'; 8 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client" 2 | export * from "./hex_string" 3 | export * from "./aptos_account" 4 | export * from "./transaction_builder" 5 | export * from "./AptosWallet" 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/index.ts: -------------------------------------------------------------------------------- 1 | export * from './metadata'; 2 | export * from './cat20Enum'; 3 | export * from './contract'; 4 | export * from './minterFinder'; 5 | export * from './btc'; 6 | export * from './common' 7 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Amount'; 2 | export * from './BigNumber'; 3 | export * from './Pda'; 4 | export * from './Program'; 5 | export * from './PublicKey'; 6 | export * from './Signer'; 7 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ], 5 | "env": { 6 | "development": { 7 | "plugins": [ 8 | "istanbul" 9 | ] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/minterFinder.ts: -------------------------------------------------------------------------------- 1 | import {MinterType} from "./cat20Enum"; 2 | 3 | export function isOpenMinter(md5: string) { 4 | return MinterType.OPEN_MINTER_V1 === md5 || MinterType.OPEN_MINTER_V2 === md5; 5 | } 6 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/index.ts: -------------------------------------------------------------------------------- 1 | export * from './beet-solana'; 2 | export * from './mpl-token-metadata'; 3 | export * from './plugins/nftModule/operations/transferNft'; 4 | export * from './utils'; 5 | export * from './types'; 6 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/signutil/schnorr/index.ts: -------------------------------------------------------------------------------- 1 | export * as secp256k1 from "./secp256k1" 2 | export * as stark from "./stark" 3 | export {SignatureType} from "./abstract/weierstrass" 4 | export {hexToBytes, bytesToHex} from "./abstract/utils" -------------------------------------------------------------------------------- /bu-packages/coin-near/src/serialize.ts: -------------------------------------------------------------------------------- 1 | export { 2 | baseEncode as base_encode, 3 | baseDecode as base_decode, 4 | serialize, 5 | deserialize, 6 | Schema, 7 | BorshError, 8 | BinaryWriter, 9 | BinaryReader, 10 | } from 'borsh'; -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/btc.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 2 | // @ts-ignore 3 | // import btc = require('bitcore-lib-inquisition'); 4 | import {btc} from '@cat-protocol/cat-smartcontracts' 5 | export {btc}; 6 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./accountAddress"; 5 | export * from "./authenticationKey"; 6 | export * from "./common"; 7 | export * from "./crypto"; 8 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api'; 2 | export * as API from './api'; 3 | 4 | export * from './wallet-api'; 5 | export * as WALLET_API from './wallet-api'; 6 | 7 | export * as PAYMASTER_API from './snip-29'; 8 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/util/bignumber.js: -------------------------------------------------------------------------------- 1 | import OriginBigNumber from 'bignumber.js'; 2 | 3 | const BigNumber = OriginBigNumber.clone(); 4 | 5 | BigNumber.DEBUG = true; // gives us exceptions on bad constructor values 6 | 7 | export default BigNumber; 8 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/lib/base/README.md: -------------------------------------------------------------------------------- 1 | # Base Module 2 | 3 | The main code of this `base` module has been migrated to the `coin-base` package. The remaining code here is retained solely for internal use within the `crypto-lib` to avoid circular dependencies. 4 | 5 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/src/v6/types.ts: -------------------------------------------------------------------------------- 1 | import { TransactionRequest as EthersTransactionRequest } from "ethers6"; 2 | 3 | export interface TransactionRequest extends EthersTransactionRequest { 4 | txSignatures?: any[]; 5 | feePayer?: string; 6 | feePayerSignatures?: any[]; 7 | } -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/bip32/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | tinySecp256k1Interface, 3 | BIP32Interface, 4 | fromSeed, 5 | fromBase58, 6 | fromPublicKey, 7 | fromPrivateKey, 8 | } from './bip32'; 9 | 10 | export { 11 | fromSeedV2, 12 | } from './bip32_v2'; 13 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Security 2 | 3 | If you find security risks, it is recommended to feedback through the following channels and get your reward! 4 | submit on HackerOne platform https://hackerone.com/okg Or on our OKX feedback submission page > security bugs https://www.okx.com/feedback/submit -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/transactionBuilder/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./helpers"; 5 | export * from "./transactionBuilder"; 6 | export * from "./remoteAbi"; 7 | export * from "./signingMessage"; -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/dict/utils/readUnaryLength.ts: -------------------------------------------------------------------------------- 1 | import { Slice } from '../../boc/Slice'; 2 | 3 | export function readUnaryLength(slice: Slice) { 4 | let res = 0; 5 | while (slice.loadBit()) { 6 | res++; 7 | } 8 | return res; 9 | } 10 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/types/gogoproto/gogo.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { Long, _m0 } from "@okxweb3/coin-base"; 3 | 4 | export const protobufPackage = "gogoproto"; 5 | 6 | if (_m0.util.Long !== Long) { 7 | _m0.util.Long = Long as any; 8 | _m0.configure(); 9 | } 10 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/version.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /** 5 | * The current version of the SDK 6 | * 7 | * hardcoded for now, we would want to have it injected dynamically 8 | */ 9 | export const VERSION = "1.4.0"; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "rootDir": "./src" 6 | }, 7 | "include": [ 8 | "src/**/*.ts" 9 | ], 10 | "exclude": [ 11 | "**/node_modules" 12 | ] 13 | } 14 | 15 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/typedData.ts: -------------------------------------------------------------------------------- 1 | // Reexport types from package 2 | export { 3 | TypedDataRevision, 4 | type StarknetEnumType, 5 | type StarknetMerkleType, 6 | type StarknetType, 7 | type StarknetDomain, 8 | type TypedData, 9 | } from './starknet-types-08'; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/types/google/api/annotations.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { Long, _m0 } from "@okxweb3/coin-base"; 3 | 4 | export const protobufPackage = "google.api"; 5 | 6 | if (_m0.util.Long !== Long) { 7 | _m0.util.Long = Long as any; 8 | _m0.configure(); 9 | } 10 | -------------------------------------------------------------------------------- /bu-packages/coin-zkspace/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './zkspace' 2 | export {zksyncChangePubkey,zksyncTransfer} from './zksync' 3 | export {closestPackableTransactionAmount,closestPackableTransactionFee} from './zksync/utils' 4 | export * from "./ZksyncWallet" 5 | export * from "./ZkspaceWallet" 6 | 7 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/bip32/bip32_v2.ts: -------------------------------------------------------------------------------- 1 | import { HDKey } from '@scure/bip32'; 2 | 3 | export function fromSeedV2(seed: Buffer, hdPath: string): HDKey { 4 | const hdkey = HDKey.fromMasterSeed(new Uint8Array([...seed])); 5 | const childKey = hdkey.derive(hdPath); 6 | return childKey; 7 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/wallet-api/index.ts: -------------------------------------------------------------------------------- 1 | export * from './constants'; 2 | export * from './typedData'; 3 | export * from './StarknetWindowObject'; 4 | export * from './components'; 5 | export * from './methods'; 6 | export * from './events'; 7 | export * from './errors'; 8 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/ton/index.ts: -------------------------------------------------------------------------------- 1 | export { WalletContractV3R2 } from './wallets/WalletContractV3R2'; 2 | export { WalletContractV4 } from './wallets/WalletContractV4'; 3 | export { WalletContractV5R1 } from './wallets/v5r1/WalletContractV5R1'; 4 | export { VenomWalletV3 } from './wallets/VenomWalletV3'; 5 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/ton/utils/maybe.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export type Maybe = T | null | undefined; -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/util/util.js: -------------------------------------------------------------------------------- 1 | export const trimEnd = (input, char) => { 2 | const isNumber = typeof input === 'number'; 3 | let str = String(input); 4 | 5 | while (str.endsWith(char)) { 6 | str = str.slice(0, -1); 7 | } 8 | 9 | return isNumber ? Number(str) : str; 10 | }; 11 | -------------------------------------------------------------------------------- /bu-packages/coin-xrp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.0.0](https://github.com/okx/js-wallet-sdk) (2025-06-18) 7 | 8 | ### New Feature 9 | 10 | - **coin-xrp:** supports xrp (https://github.com/okx/js-wallet-sdk) 11 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/kava/auction/v1beta1/tx.amino.ts: -------------------------------------------------------------------------------- 1 | import { MsgPlaceBid } from "./tx"; 2 | export const AuctionAminoConverter = { 3 | "/kava.auction.v1beta1.MsgPlaceBid": { 4 | aminoType: "auction/MsgPlaceBid", 5 | toAmino: MsgPlaceBid.toAmino, 6 | fromAmino: MsgPlaceBid.fromAmino 7 | } 8 | }; -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/utils/maybe.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export type Maybe = T | null | undefined; -------------------------------------------------------------------------------- /examples/src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as ReactDOM from "react-dom/client" 3 | import { App } from "./App" 4 | 5 | const root = ReactDOM.createRoot(document.getElementById('root')!); 6 | 7 | root.render( 8 | 9 | 10 | , 11 | ) 12 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/utils/misc.ts: -------------------------------------------------------------------------------- 1 | export const DEFAULT_MAX_GAS_AMOUNT = 200000; 2 | // Transaction expire timestamp 3 | export const DEFAULT_TXN_EXP_SEC_FROM_NOW = 20; 4 | // How long does SDK wait for txn to finish 5 | export const DEFAULT_TXN_TIMEOUT_SEC = 20; 6 | export const APTOS_COIN = "0x1::aptos_coin::AptosCoin"; -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/spl/instructions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types'; 2 | export * from './transfer'; 3 | export * from './transferChecked'; 4 | export * from './associatedTokenAccount'; 5 | export * from './burn'; 6 | export * from './burnChecked'; 7 | export * from './mintTo'; 8 | export * from './mintToChecked'; 9 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./account"; 5 | export * from "./api"; 6 | export * from "./bcs"; 7 | export * from "./core"; 8 | export * from "./transactions"; 9 | export * from "./types"; 10 | export * from "./utils"; -------------------------------------------------------------------------------- /docs/_coverpage.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ![logo](media/logo.png) 4 | 5 | # js-wallet-sdk 6 | 7 | 8 | - Generic Architecture, easy to extend and maintain 9 | - Fully Browser Compatible 10 | - Support for Bitcoin, Ethereum, Cosmos, Aptos, Sol ... 11 | 12 | [GitHub](https://github.com/okx/js-wallet-sdk) 13 | 14 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/blockhash.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src 4 | */ 5 | 6 | /** 7 | * Blockhash as Base58 string. 8 | */ 9 | export type Blockhash = string; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/helpers/valuesType.ts: -------------------------------------------------------------------------------- 1 | export type ValuesType | ArrayLike | Record> = 2 | T extends ReadonlyArray 3 | ? T[number] 4 | : T extends ArrayLike 5 | ? T[number] 6 | : T extends object 7 | ? T[keyof T] 8 | : never; 9 | -------------------------------------------------------------------------------- /bu-packages/coin-tron/src/lib/protobuf/attribution.md: -------------------------------------------------------------------------------- 1 | # Attribution for module protobuf 2 | 3 | We got the proto from the `tronprotocol`, thanks for their work, we could write this useful sdk for tron blockchain 4 | 5 | https://github.com/tronprotocol/java-tron/tree/9f8cebd1ff2601b7779715de9b66a7b84f4effdd/protocol/src/main/protos/core 6 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transactions'; 2 | export * from './stacking'; 3 | export * from './network'; 4 | export * from './c32check'; 5 | export * from './transaction'; 6 | export {bytesToHex} from './common'; 7 | export {hashMessage,verifyMessageSignatureRsv} from './encryption'; 8 | export * from "./Stxwallet" 9 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./authenticator"; 5 | export * from "./instances"; 6 | export * from "./transactionBuilder"; 7 | export * from "./typeTag"; 8 | export * from "./typeTag/parser"; 9 | export * from "./types"; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-eos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "resolveJsonModule" : true, 5 | "outDir": "./dist", 6 | "rootDir": "./src" 7 | }, 8 | "include": [ 9 | "src/**/*.ts", 10 | "src/**/*.json" 11 | ], 12 | "exclude": [ 13 | "**/node_modules" 14 | ] 15 | } 16 | 17 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/base64.ts: -------------------------------------------------------------------------------- 1 | import { base64 } from "@scure/base" 2 | 3 | export function toBase64(data: Uint8Array | Buffer | Number[]): string { 4 | const a = Buffer.from(data) 5 | return base64.encode(Uint8Array.from(a)) 6 | } 7 | 8 | export function fromBase64(data: string): Uint8Array { 9 | return base64.decode(data) 10 | } -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/utils/utxo.ts: -------------------------------------------------------------------------------- 1 | import {UTXO} from 'scrypt-ts'; 2 | 3 | 4 | export function pickLargeFeeUtxo(feeUtxos: Array): UTXO { 5 | let max = feeUtxos[0]; 6 | 7 | for (const utxo of feeUtxos) { 8 | if (utxo.satoshis > max.satoshis) { 9 | max = utxo; 10 | } 11 | } 12 | return max; 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/provider/types/index.type.ts: -------------------------------------------------------------------------------- 1 | export * from './configuration.type'; 2 | export * from './response.type'; 3 | 4 | // TODO: resolve what types to export on top level 5 | // TODO: option to add StableProvider that use provider types and Provider that use normal types, than export Stable under some namespace 6 | export * from './spec.type'; 7 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from './methods'; 2 | export * as CONTRACT from './contract'; 3 | export * from './errors'; 4 | export * from './components'; 5 | export * from './nonspec'; 6 | export * from './constants'; 7 | export * from './executable'; 8 | 9 | export * from './expansions/transactionReceipt'; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/builder/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from './TransactionBlock'; 5 | export {TransactionBlockDataBuilder} from './TransactionBlockData'; 6 | export * from './Transactions'; 7 | export * from './Inputs'; 8 | export * from './bcs'; 9 | export * from './serializer'; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/encryption/hashRipemd160.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | import { base } from '@okxweb3/coin-base'; 9 | 10 | export function hashRipemd160(data: Uint8Array) { 11 | return base.ripemd160(data); 12 | } 13 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/base58.ts: -------------------------------------------------------------------------------- 1 | import { base58 } from "@scure/base" 2 | export function toBase58(data: Uint8Array | Buffer | Number[]): string { 3 | const a = Buffer.from(data) 4 | return base58.encode(Uint8Array.from(a)) 5 | } 6 | 7 | export function fromBase58(data: string): Uint8Array { 8 | return base58.decode(data) 9 | } 10 | 11 | export {base58} -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/wallet/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BtcWallet" 2 | export * from "./BchWallet" 3 | export * from "./BsvWallet" 4 | export * from "./DogeWallet" 5 | export * from "./LtcWallet" 6 | export * from "./UsdtWallet" 7 | export * from "./RuneWallet" 8 | export * from "./RuneMainWallet" 9 | export * from "./AtomicalWallet" 10 | export * from "./CatWallet" 11 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/kava/aminotypes.ts: -------------------------------------------------------------------------------- 1 | import {AuctionAminoConverter} from "./auction/v1beta1/tx.amino"; 2 | import {HardAminoConverter} from "./hard/v1beta1/tx.amino"; 3 | import {SwapAminoConverter} from "./swap/v1beta1/tx.amino"; 4 | 5 | export const KavaAminoConverters = { 6 | ...AuctionAminoConverter, 7 | ...HardAminoConverter, 8 | ...SwapAminoConverter 9 | } -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/base-x/index.d.ts: -------------------------------------------------------------------------------- 1 | declare function base(ALPHABET: string): base.BaseConverter; 2 | export = base; 3 | declare namespace base { 4 | interface BaseConverter { 5 | encode(buffer: Uint8Array | number[]): string; 6 | decodeUnsafe(string: string): Uint8Array | undefined; 7 | decode(string: string): Uint8Array; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/lib/base/base58.ts: -------------------------------------------------------------------------------- 1 | import { base58 } from "@scure/base" 2 | export function toBase58(data: Uint8Array | Buffer | Number[]): string { 3 | const a = Buffer.from(data) 4 | return base58.encode(Uint8Array.from(a)) 5 | } 6 | 7 | export function fromBase58(data: string): Uint8Array { 8 | return base58.decode(data) 9 | } 10 | 11 | export {base58} -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/boc/Writable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Builder } from "./Builder"; 10 | 11 | export type Writable = { writeTo: (builder: Builder) => void }; -------------------------------------------------------------------------------- /bu-packages/coin-base/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /bu-packages/coin-kaia/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule" : true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/utils/properties.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export function defineReadOnly( 5 | object: T, 6 | name: K, 7 | value: T[K], 8 | ): void { 9 | Object.defineProperty(object, name, { 10 | enumerable: true, 11 | value: value, 12 | writable: false, 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /bu-packages/coin-tron/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/bcs/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./deserializer"; 5 | export * from "./serializer"; 6 | export * from "./serializable/entryFunctionBytes"; 7 | export * from "./serializable/fixedBytes"; 8 | export * from "./serializable/movePrimitives"; 9 | export * from "./serializable/moveStructs"; 10 | -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/elliptic/curve/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * LICENSE 3 | * This software is licensed under the MIT License. 4 | * 5 | * Copyright Fedor Indutny, 2014. 6 | * */ 7 | 'use strict'; 8 | 9 | var curve = exports; 10 | 11 | curve.base = require('./base'); 12 | curve.short = require('./short'); 13 | curve.mont = require('./mont'); 14 | curve.edwards = require('./edwards'); 15 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /bu-packages/coin-near/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "resolveJsonModule" : true, 5 | "strictPropertyInitialization": false, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.json" 12 | ], 13 | "exclude": [ 14 | "**/node_modules" 15 | ] 16 | } 17 | 18 | -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule" : true, 6 | "outDir": "./dist", 7 | "rootDir": "./src" 8 | }, 9 | "include": [ 10 | "src/**/*.ts", 11 | "src/**/*.js", 12 | "src/**/*.json" 13 | ], 14 | "exclude": [ 15 | "**/node_modules" 16 | ] 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/encryption/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | export * from './keys'; 9 | export * from './cryptoRandom'; 10 | export * from './sha2Hash'; 11 | export * from './utils'; 12 | export * from './messageSignature'; 13 | export * from './ec'; 14 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | 7 | 8 | # [1.0.1](https://github.com/okx/js-wallet-sdk)(2024-02-19) 9 | 10 | ### New Features 11 | 12 | - **coin-kaia:** overrides elliptic 13 | 14 | # [1.0.0](https://github.com/okx/js-wallet-sdk)(2024-02-18) 15 | 16 | ### New Features 17 | 18 | - **coin-kaia:** support kaia -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/crypto/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./ed25519"; 5 | export * from "./hdKey"; 6 | export * from "./multiEd25519"; 7 | export * from "./multiKey"; 8 | export * from "./privateKey"; 9 | export * from "./publicKey"; 10 | export * from "./secp256k1"; 11 | export * from "./signature"; 12 | export * from "./singleKey"; 13 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-kaspa/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/json/numberParsers.ts: -------------------------------------------------------------------------------- 1 | import { LosslessNumber } from './LosslessNumber' 2 | import { isInteger } from './utils' 3 | 4 | export function parseLosslessNumber(value: string): LosslessNumber { 5 | return new LosslessNumber(value) 6 | } 7 | 8 | export function parseNumberAndBigInt(value: string): number | bigint { 9 | return isInteger(value) ? BigInt(value) : parseFloat(value) 10 | } -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/util/checksum.js: -------------------------------------------------------------------------------- 1 | export function verifyChecksum(expected, actual) { 2 | if (expected.length !== actual.length) { 3 | return false; 4 | } 5 | 6 | if (expected.length === 0) { 7 | return true; 8 | } 9 | 10 | for (let i = 0; i < expected.length; i += 1) { 11 | if (expected[i] !== actual[i]) { 12 | return false; 13 | } 14 | } 15 | 16 | return true; 17 | } 18 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/boc/CellType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export enum CellType { 10 | Ordinary = -1, 11 | PrunedBranch = 1, 12 | Library = 2, 13 | MerkleProof = 3, 14 | MerkleUpdate = 4 15 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/generated/models/HexEncodedBytes.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | /** 6 | * All bytes (Vec) data is represented as hex-encoded string prefixed with `0x` and fulfilled with 7 | * two hex digits per byte. 8 | * 9 | * Unlike the `Address` type, HexEncodedBytes will not trim any zeros. 10 | * 11 | */ 12 | export type HexEncodedBytes = string; 13 | -------------------------------------------------------------------------------- /bu-packages/coin-cardano/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-zkspace/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true 9 | }, 10 | "include": [ 11 | "src/**/*.ts", 12 | "src/**/*.js", 13 | "src/**/*.json" 14 | ], 15 | "exclude": [ 16 | "**/node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/hmac.ts: -------------------------------------------------------------------------------- 1 | import {Input} from "@noble/hashes/utils"; 2 | 3 | import {hmac} from "@noble/hashes/hmac" 4 | import {sha256, sha512} from "./hash" 5 | 6 | export function hmacSHA256(key: Input, buffer: Input): Buffer { 7 | return Buffer.from(hmac(sha256, key, buffer)); 8 | } 9 | 10 | export function hmacSHA512(key: Input, buffer: Input): Buffer { 11 | return Buffer.from(hmac(sha512, key, buffer)); 12 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/bcs/index.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | export * from "./types"; 10 | export * from "./serializer"; 11 | export * from "./deserializer"; 12 | export * from "./helper"; 13 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/lib/base/hmac.ts: -------------------------------------------------------------------------------- 1 | import {Input} from "@noble/hashes/utils"; 2 | 3 | import {hmac} from "@noble/hashes/hmac" 4 | import {sha256, sha512} from "./hash" 5 | 6 | export function hmacSHA256(key: Input, buffer: Input): Buffer { 7 | return Buffer.from(hmac(sha256, key, buffer)); 8 | } 9 | 10 | export function hmacSHA512(key: Input, buffer: Input): Buffer { 11 | return Buffer.from(hmac(sha512, key, buffer)); 12 | } -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "types": [ 8 | "@types/jest" 9 | ], 10 | "rootDir": "./src" 11 | }, 12 | "include": [ 13 | "src/**/*.ts", 14 | "src/**/*.js", 15 | "src/**/*.json" 16 | ], 17 | "exclude": [ 18 | "**/node_modules" 19 | ] 20 | } -------------------------------------------------------------------------------- /bu-packages/coin-kaia/src/api.ts: -------------------------------------------------------------------------------- 1 | import {base} from "@okxweb3/coin-base" 2 | 3 | export function validPrivateKey(privateKeyHex: string): boolean { 4 | if (!base.validateHexString(privateKeyHex)) { 5 | return false; 6 | } 7 | const privateKey = base.fromHex(privateKeyHex.toLowerCase()) 8 | if (privateKey.length != 32 || privateKey.every(byte => byte === 0)) { 9 | return false; 10 | } 11 | return true; 12 | } -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/common/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | export * from './config'; 9 | export * from './errors'; 10 | export * from './logger'; 11 | export * from './utils'; 12 | export * from './constants'; 13 | export * from './signatures'; 14 | export * from './keys'; 15 | export * from './buffer'; -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/utils/assert.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src/utils 4 | */ 5 | 6 | export default function ( 7 | condition: unknown, 8 | message?: string, 9 | ): asserts condition { 10 | if (!condition) { 11 | throw new Error(message || 'Assertion failed'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/wallet-api/StarknetWindowObject.ts: -------------------------------------------------------------------------------- 1 | import type { WalletEventListener } from './events'; 2 | import type { RequestFn } from './methods'; 3 | 4 | export interface StarknetWindowObject { 5 | id: string; 6 | name: string; 7 | version: string; 8 | icon: string | { dark: string; light: string }; 9 | request: RequestFn; 10 | on: WalletEventListener; 11 | off: WalletEventListener; 12 | } 13 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/signers/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { SerializedSignature } from '../cryptography/signature'; 5 | 6 | export type SignedTransaction = { 7 | transactionBlockBytes: string; 8 | hash: string; 9 | signature: SerializedSignature; 10 | }; 11 | 12 | export type SignedMessage = { 13 | messageBytes: string; 14 | signature: SerializedSignature; 15 | }; 16 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/src/v6/index.ts: -------------------------------------------------------------------------------- 1 | // Pass-through js-ext-core exports 2 | // export * from "@kaiachain/js-ext-core/util"; 3 | export { 4 | AccountKey, 5 | AccountKeyFactory, 6 | KlaytnTx, 7 | KlaytnTxFactory, 8 | parseTransaction, 9 | } from "@kaiachain/js-ext-core"; 10 | 11 | // ethers-ext classes and functions 12 | export * from "./accountStore"; 13 | export * from "./keystore"; 14 | export * from "./signer"; 15 | export * from "./txutil"; 16 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/index.ts: -------------------------------------------------------------------------------- 1 | export * from './blockhash'; 2 | export * from './fee-calculator'; 3 | export * from './keypair'; 4 | export * from './message'; 5 | export * from './nonce-account'; 6 | export * from './programs'; 7 | export * from './publickey'; 8 | export * from './transaction'; 9 | export * from './sysvar'; 10 | 11 | /** 12 | * There are 1-billion lamports in one SOL 13 | */ 14 | export const LAMPORTS_PER_SOL = 1000000000; 15 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AuthorityType'; 2 | export * from './AuthorizationData'; 3 | export * from './DelegateArgs'; 4 | export * from './LeafInfo'; 5 | export * from './MetadataDelegateRole'; 6 | export * from './Payload'; 7 | export * from './PayloadType'; 8 | export * from './SeedsVec'; 9 | export * from './TokenDelegateRole'; 10 | export * from './TokenStandard'; 11 | export * from './TransferArgs'; 12 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node/sha256.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import crypto from 'crypto'; 10 | 11 | export async function sha256(source: Buffer | string): Promise { 12 | return crypto.createHash('sha256').update(source).digest(); 13 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node/sha512.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import crypto from 'crypto'; 10 | 11 | export async function sha512(source: Buffer | string): Promise { 12 | return crypto.createHash('sha512').update(source).digest(); 13 | } -------------------------------------------------------------------------------- /bu-packages/coin-xrp/src/const.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | export const ZERO_SEED_ED25519 = "sEdSJHS4oiAdz7w2X2ni1gFiqtbJHqE" 5 | export const ZERO_SEED_SECP256 = "sp6JS7f14BuwFY8Mw6bTtLKWauoUs" 6 | 7 | export const INVALID_ADDRESS = ["rrrrrrrrrrrrrrrrrrrrrhoLvTp","rrrrrrrrrrrrrrrrrrrrBZbvji", 8 | "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","rrrrrrrrrrrrrrrrrNAMEtxvNvQ","rrrrrrrrrrrrrrrrrrrn5RM1rHd"]; 9 | 10 | export const PREFIX_ED25519 = "ED" 11 | export const PREFIX_SECP256K1 = "00" -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/elliptic/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * LICENSE 3 | * This software is licensed under the MIT License. 4 | * 5 | * Copyright Fedor Indutny, 2014. 6 | * */ 7 | 8 | 'use strict'; 9 | 10 | const curve = require('./curve'); 11 | const curves = require('./curves'); 12 | 13 | // Protocols 14 | const ec = require('./ec'); 15 | const eddsa = require('./eddsa'); 16 | 17 | const utils = require('./utils') 18 | 19 | export {ec, eddsa, curve, curves, utils} 20 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "resolveJsonModule": true, 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "experimentalDecorators": true, 9 | "lib": [ 10 | "dom" 11 | ] 12 | }, 13 | "include": [ 14 | "src/**/*.ts", 15 | "src/**/*.js", 16 | "src/**/*.json" 17 | ], 18 | "exclude": [ 19 | "**/node_modules" 20 | ] 21 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/index.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | export * from "./builder"; 10 | export * as BCS from "./bcs"; 11 | export * as TxnBuilderTypes from "./aptos_types"; 12 | export * as MoveTypes from "./move_types"; 13 | 14 | -------------------------------------------------------------------------------- /bu-packages/coin-xrp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "suppressImplicitAnyIndexErrors": true, 5 | "noImplicitAny": false, 6 | "allowJs": true, 7 | "resolveJsonModule" : true, 8 | "outDir": "./dist", 9 | "rootDir": "./src" 10 | }, 11 | "include": [ 12 | "src/**/*.ts", 13 | "src/**/*.js", 14 | "src/**/*.json" 15 | ], 16 | "exclude": [ 17 | "**/node_modules" 18 | ] 19 | } 20 | 21 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/base58Check.ts: -------------------------------------------------------------------------------- 1 | import {sha256} from "./hash"; 2 | 3 | import { base58check } from "@scure/base" 4 | 5 | export function toBase58Check(data: Uint8Array | Buffer | Number[]): string { 6 | const bytesCoder = base58check(sha256); 7 | return bytesCoder.encode(Buffer.from(data)) 8 | } 9 | 10 | export function fromBase58Check(data: string): Buffer { 11 | const bytesCoder = base58check(sha256); 12 | return Buffer.from(bytesCoder.decode(data)) 13 | } -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/bip174/parser/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `bitcoinjs`, thanks for their work 3 | * https://github.com/bitcoinjs/bitcoinjs-lib 4 | */ 5 | import { PsbtGlobal, PsbtInput, PsbtOutput } from '../interfaces'; 6 | 7 | export * from './fromBuffer'; 8 | export * from './toBuffer'; 9 | 10 | export interface PsbtAttributes { 11 | globalMap: PsbtGlobal; 12 | inputs: PsbtInput[]; 13 | outputs: PsbtOutput[]; 14 | } 15 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/common/config.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | 9 | // import { network } from './network' 10 | 11 | /** 12 | * @ignore 13 | */ 14 | const config = { 15 | // network: network.defaults.MAINNET_DEFAULT, 16 | network: { 17 | layer1: 'placeholder', 18 | }, 19 | logLevel: 'debug', 20 | }; 21 | 22 | export { config }; -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | // bip32 Seed - Master private key - Derived private key 2 | export * as bip32 from "./bip32" 3 | 4 | // bip39 Mnemonics - Seeds 5 | export * as bip39 from "./bip39" 6 | 7 | // Encryption library, support secp256k1 and ed25519 8 | export * as elliptic from "./elliptic" 9 | 10 | export * as signUtil from "./signutil" 11 | 12 | export * as ed25519 from "@noble/ed25519" 13 | 14 | export * as secp256k1 from "@noble/secp256k1" 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib'; 2 | export * from '../provider/types/index.type'; 3 | 4 | export * from './account'; 5 | export * from './cairoEnum'; 6 | export * from './calldata'; 7 | export * from './contract'; 8 | export * from './errors'; 9 | export * from './outsideExecution'; 10 | export * from './signer'; 11 | export * from '../utils/transactionReceipt/transactionReceipt.type'; 12 | export * from './typedData'; 13 | 14 | export * as RPC from './api'; 15 | -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/src/keys.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Author:https://github.com/nbd-wtf/nostr-tools 3 | * */ 4 | import {secp256k1} from "@okxweb3/crypto-lib"; 5 | import {base} from "@okxweb3/coin-base"; 6 | 7 | export function generatePrivateKey(): string { 8 | return base.toHex(secp256k1.utils.randomPrivateKey(),false) 9 | } 10 | 11 | export function getPublicKey(privateKey: string): string { 12 | return base.toHex(secp256k1.schnorr.getPublicKey(base.stripHexPrefix(privateKey)),false) 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/json/index.ts: -------------------------------------------------------------------------------- 1 | export { parse } from './parse' 2 | export { stringify } from './stringify' 3 | export { LosslessNumber, isLosslessNumber, toLosslessNumber } from './LosslessNumber' 4 | export { parseLosslessNumber, parseNumberAndBigInt } from './numberParsers' 5 | export { 6 | UnsafeNumberReason, 7 | isInteger, 8 | isNumber, 9 | isSafeNumber, 10 | toSafeNumberOrThrow, 11 | getUnsafeNumberReason 12 | } from './utils' 13 | export * from './types' -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/bip174/converter/global/unsignedTx.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `bitcoinjs`, thanks for their work 3 | * https://github.com/bitcoinjs/bitcoinjs-lib 4 | */ 5 | import { KeyValue, Transaction } from '../../interfaces'; 6 | import { GlobalTypes } from '../../typeFields'; 7 | 8 | export function encode(data: Transaction): KeyValue { 9 | return { 10 | key: Buffer.from([GlobalTypes.UNSIGNED_TX]), 11 | value: data.toBuffer(), 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-eos/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-eos:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2023-12-21) 13 | 14 | ### Feature 15 | 16 | - **coin-eos:** update for wax or eos token ([49](https://github.com/okx/js-wallet-sdk/pull/49)) 17 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const ETH = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; 2 | export const STRK = "0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D" 3 | export const ETHBridge = "0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"; 4 | export const ProxyAccountClassHash = "0x3530cc4759d78042f1b543bf797f5f3d647cde0388c33734cf91b7f7b9314a9"; 5 | export const accountClassHash = "0x309c042d3729173c7f2f91a34f04d8c509c1b292d334679ef1aabf8da0899cc"; -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/types/SendMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export enum SendMode { 10 | CARRY_ALL_REMAINING_BALANCE = 128, 11 | CARRY_ALL_REMAINING_INCOMING_VALUE = 64, 12 | DESTROY_ACCOUNT_IF_ZERO = 32, 13 | PAY_GAS_SEPARATELY = 1, 14 | IGNORE_ERRORS = 2, 15 | NONE = 0 16 | } 17 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/instances/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from "./chainId"; 5 | export * from "./identifier"; 6 | export * from "./moduleId"; 7 | export * from "./rawTransaction"; 8 | export * from "./rotationProofChallenge"; 9 | export * from "./signedTransaction"; 10 | export * from "./transactionArgument"; 11 | export * from "./transactionPayload"; 12 | export * from "./simpleTransaction"; 13 | export * from "./multiAgentTransaction"; 14 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/abi/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Mozilla Public License Version 2.0 3 | * 4 | * 5 | * https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/util/LICENSE 6 | * 7 | * */ 8 | 9 | const ABI = require("./abi.js") 10 | function RawEncode(types: string[], values: any[]): Buffer { 11 | return ABI.rawEncode(types, values) 12 | } 13 | 14 | function SoliditySHA3(types: string[], values: any[]): Buffer { 15 | return ABI.soliditySHA3(types, values) 16 | } 17 | 18 | export {ABI, RawEncode, SoliditySHA3} -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/src/lib/sdk/ethereumjs-util/externals.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `ethereumjs/util`, thanks for their work 3 | * https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util 4 | * Distributed under the Mozilla Public License Version 2.0 software license, see the accompanying 5 | * file LICENSE or https://opensource.org/license/mpl-2-0/. 6 | */ 7 | 8 | import { BN } from '@okxweb3/coin-base'; 9 | import * as rlp from './rlp'; 10 | export { BN }; 11 | export { rlp }; 12 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | 7 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 8 | 9 | ### New Features 10 | 11 | - **coin-starknet:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 12 | 13 | # [1.0.4](https://github.com/okx/js-wallet-sdk) (2024-08-20) 14 | 15 | ### Fix 16 | 17 | - **coin-starknet:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 18 | 19 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/connect/fetch.ts: -------------------------------------------------------------------------------- 1 | import { LibraryError } from '../errors'; 2 | 3 | export default (typeof globalThis !== 'undefined' && globalThis.fetch.bind(globalThis)) || 4 | (typeof window !== 'undefined' && window.fetch.bind(window)) || 5 | (typeof global !== 'undefined' && global.fetch.bind(global)) || 6 | ((() => { 7 | throw new LibraryError( 8 | "'fetch()' not detected, use the 'baseFetch' constructor parameter to set it" 9 | ); 10 | }) as WindowOrWorkerGlobalScope['fetch']); 11 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/types/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export * from './common'; 5 | export * from './objects'; 6 | export * from './events'; 7 | export * from './transactions'; 8 | export * from '../framework/framework'; 9 | export * from './sui-bcs'; 10 | export * from './faucet'; 11 | export * from './normalized'; 12 | export * from './validator'; 13 | export * from './coin'; 14 | export { GasCostSummary, CheckpointDigest, Checkpoint } from './checkpoints'; 15 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/utils/format.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | const ELLIPSIS = '\u{2026}'; 5 | 6 | export function formatAddress(address: string) { 7 | const offset = address.startsWith('0x') ? 2 : 0; 8 | 9 | return `0x${address.slice(offset, offset + 4)}${ELLIPSIS}${address.slice( 10 | -4, 11 | )}`; 12 | } 13 | 14 | export function formatDigest(digest: string) { 15 | // Use 10 first characters 16 | return `${digest.slice(0, 10)}${ELLIPSIS}`; 17 | } 18 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/common.ts: -------------------------------------------------------------------------------- 1 | export enum BtcXrcTypes { 2 | INSCRIBE = 1, 3 | PSBT = 2, 4 | PSBT_MPC_UNSIGNED_LIST = 21, 5 | PSBT_MPC_SIGNED_LIST = 22, 6 | PSBT_MPC_UNSIGNED_BUY = 23, 7 | PSBT_MPC_SIGNED_BUY = 24, 8 | PSBT_MPC_UNSIGNED = 25, 9 | PSBT_MPC_SIGNED = 26, 10 | PSBT_RUNEMAIN = 27, 11 | PSBT_KEY_SCRIPT_PATH = 3, 12 | PSBT_KEY_SCRIPT_PATH_BATCH = 4, 13 | SRC20 = 101, 14 | RUNE = 102, 15 | RUNEMAIN = 103, 16 | PSBT_DEODE = 104, 17 | ARC20 = 114, 18 | CAT20 = 115, 19 | } -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-nostrassets:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.2](https://github.com/okx/js-wallet-sdk) (2023-11-28) 13 | 14 | ### New Features 15 | 16 | - **coin-nostrassets:** support private key with 'nsec' prefix ([35](https://github.com/okx/js-wallet-sdk/pull/35)) -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./bitcoinjs-lib" 2 | export * from "./bitcoincash" 3 | export * from "./txBuild" 4 | export * from "./type" 5 | export * as wif from "./wif" 6 | export * from "./src20" 7 | export * from "./inscribe" 8 | // @ts-ignore 9 | export * from "./inscribe_refund_fee" 10 | export * from "./doginals" 11 | export * from "./psbtSign" 12 | export * as message from "./message" 13 | export * from "./wallet/index" 14 | export * from "./onekey" 15 | export * from "./common" 16 | export * from "./cat20" 17 | export * from "./taproot" -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/builder/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { create as superstructCreate, Struct } from 'superstruct'; 5 | 6 | export function create(value: T, struct: Struct): T { 7 | return superstructCreate(value, struct); 8 | } 9 | 10 | export type WellKnownEncoding = 11 | | { 12 | kind: 'object'; 13 | } 14 | | { 15 | kind: 'pure'; 16 | type: string; 17 | }; 18 | 19 | export const TRANSACTION_TYPE = Symbol('transaction-argument-type'); 20 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export { getSecureRandomBytes, getSecureRandomWords } from './node/getSecureRandom'; 10 | export { hmac_sha512 } from './node/hmac_sha512'; 11 | export { pbkdf2_sha512 } from './node/pbkdf2_sha512'; 12 | export { sha256 } from './node/sha256'; 13 | export { sha512 } from './node/sha512'; -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/types/option.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export type Option = 5 | | T 6 | | { 7 | fields: { 8 | vec: ''; 9 | }; 10 | type: string; 11 | }; 12 | 13 | export function getOption(option: Option): T | undefined { 14 | if ( 15 | typeof option === 'object' && 16 | option !== null && 17 | 'type' in option && 18 | option.type.startsWith('0x1::option::Option<') 19 | ) { 20 | return undefined; 21 | } 22 | return option as T; 23 | } 24 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/contract/ContractState.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Maybe } from "../utils/maybe"; 10 | 11 | export type ContractState = { 12 | balance: bigint, 13 | last: { lt: bigint, hash: Buffer } | null, 14 | state: { type: 'uninit' } | { type: 'active', code: Maybe, data: Maybe } | { type: 'frozen', stateHash: Buffer } 15 | }; -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/bech32.ts: -------------------------------------------------------------------------------- 1 | import {bech32} from "@scure/base"; 2 | 3 | export function toBech32(prefix: string, data: Buffer | Uint8Array | Number[], limit?: number | false): string { 4 | const a = Buffer.from(data) 5 | const bit5 = bech32.toWords(Uint8Array.from(a)) 6 | return bech32.encode(prefix, bit5, limit) 7 | } 8 | 9 | export function fromBech32(data: string, limit?: number | false): [string, Buffer] { 10 | const d = bech32.decode(data as any, limit) 11 | const bit8 = bech32.fromWords(d.words) 12 | return [d.prefix, Buffer.from(bit8)] 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/operations/inflation.js: -------------------------------------------------------------------------------- 1 | import xdr from '../xdr'; 2 | 3 | /** 4 | * This operation generates the inflation. 5 | * @function 6 | * @alias Operation.inflation 7 | * @param {object} [opts] Options object 8 | * @param {string} [opts.source] - The optional source account. 9 | * @returns {xdr.InflationOp} Inflation operation 10 | */ 11 | export function inflation(opts = {}) { 12 | const opAttributes = {}; 13 | opAttributes.body = xdr.OperationBody.inflation(); 14 | this.setSourceAccount(opAttributes, opts); 15 | return new xdr.Operation(opAttributes); 16 | } 17 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/utils/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `utils`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/utils 4 | */ 5 | export type PartialKeys = Omit< 6 | T, 7 | K 8 | > & 9 | Partial>; 10 | 11 | export type RequiredKeys = Omit< 12 | T, 13 | K 14 | > & 15 | Required>; 16 | 17 | export type Option = T | null; 18 | 19 | export type Opaque = T & { __opaque__: K }; 20 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/utils/to-buffer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src/utils 4 | */ 5 | 6 | import {Buffer} from 'buffer'; 7 | 8 | export const toBuffer = (arr: Buffer | Uint8Array | Array): Buffer => { 9 | if (Buffer.isBuffer(arr)) { 10 | return arr; 11 | } else if (arr instanceof Uint8Array) { 12 | return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength); 13 | } else { 14 | return Buffer.from(arr); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/varuint.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `bitcoinjs`, thanks for their work 3 | * https://github.com/bitcoinjs/bitcoinjs-lib 4 | */ 5 | /// 6 | interface Encode { 7 | (num: number, buffer?: Buffer, offset?: number): Buffer; 8 | bytes: number; 9 | } 10 | declare const encode: Encode; 11 | interface Decode { 12 | (buffer: Buffer, offset?: number): number; 13 | bytes: number; 14 | } 15 | declare const decode: Decode; 16 | declare function encodingLength(num: number): number; 17 | export { encode, decode, encodingLength }; -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/bcs/types.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | export type Seq = T[]; 10 | 11 | export type Uint8 = number; 12 | export type Uint16 = number; 13 | export type Uint32 = number; 14 | export type Uint64 = bigint; 15 | export type Uint128 = bigint; 16 | export type Uint256 = bigint; 17 | export type AnyNumber = bigint | number; 18 | export type Bytes = Uint8Array; -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/numbers/int128.js: -------------------------------------------------------------------------------- 1 | import { LargeInt } from '@stellar/js-xdr'; 2 | 3 | export class Int128 extends LargeInt { 4 | /** 5 | * Construct a signed 128-bit integer that can be XDR-encoded. 6 | * 7 | * @param {Array} args - one or more slices to encode 8 | * in big-endian format (i.e. earlier elements are higher bits) 9 | */ 10 | constructor(...args) { 11 | super(args); 12 | } 13 | 14 | get unsigned() { 15 | return false; 16 | } 17 | 18 | get size() { 19 | return 128; 20 | } 21 | } 22 | 23 | Int128.defineIntBoundaries(); 24 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/numbers/int256.js: -------------------------------------------------------------------------------- 1 | import { LargeInt } from '@stellar/js-xdr'; 2 | 3 | export class Int256 extends LargeInt { 4 | /** 5 | * Construct a signed 256-bit integer that can be XDR-encoded. 6 | * 7 | * @param {Array} args - one or more slices to encode 8 | * in big-endian format (i.e. earlier elements are higher bits) 9 | */ 10 | constructor(...args) { 11 | super(args); 12 | } 13 | 14 | get unsigned() { 15 | return false; 16 | } 17 | 18 | get size() { 19 | return 256; 20 | } 21 | } 22 | 23 | Int256.defineIntBoundaries(); 24 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node/getSecureRandom.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import crypto from 'crypto'; 10 | 11 | export function getSecureRandomBytes(size: number): Buffer { 12 | return crypto.randomBytes(size); 13 | } 14 | 15 | export function getSecureRandomWords(size: number): Uint16Array { 16 | let res = new Uint16Array(size); 17 | crypto.randomFillSync(res); 18 | return res; 19 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/transaction/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src/transaction 4 | */ 5 | 6 | /** 7 | * Maximum over-the-wire size of a Transaction 8 | * 9 | * 1280 is IPv6 minimum MTU 10 | * 40 bytes is the size of the IPv6 header 11 | * 8 bytes is the size of the fragment header 12 | */ 13 | export const PACKET_DATA_SIZE = 1280 - 40 - 8; 14 | 15 | export const VERSION_PREFIX_MASK = 0x7f; 16 | 17 | export const SIGNATURE_LENGTH_IN_BYTES = 64; 18 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/connect/ws.ts: -------------------------------------------------------------------------------- 1 | import { LibraryError } from '../errors'; 2 | 3 | export default (typeof WebSocket !== 'undefined' && WebSocket) || 4 | (typeof globalThis !== 'undefined' && globalThis.WebSocket) || 5 | (typeof window !== 'undefined' && window.WebSocket.bind(window)) || 6 | (typeof global !== 'undefined' && global.WebSocket) || 7 | (class { 8 | constructor() { 9 | throw new LibraryError( 10 | "WebSocket module not detected, use the 'websocket' constructor parameter to set a compatible connection" 11 | ); 12 | } 13 | } as unknown as typeof WebSocket); 14 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/numbers/uint128.js: -------------------------------------------------------------------------------- 1 | import { LargeInt } from '@stellar/js-xdr'; 2 | 3 | export class Uint128 extends LargeInt { 4 | /** 5 | * Construct an unsigned 128-bit integer that can be XDR-encoded. 6 | * 7 | * @param {Array} args - one or more slices to encode 8 | * in big-endian format (i.e. earlier elements are higher bits) 9 | */ 10 | constructor(...args) { 11 | super(args); 12 | } 13 | 14 | get unsigned() { 15 | return true; 16 | } 17 | 18 | get size() { 19 | return 128; 20 | } 21 | } 22 | 23 | Uint128.defineIntBoundaries(); 24 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/numbers/uint256.js: -------------------------------------------------------------------------------- 1 | import { LargeInt } from '@stellar/js-xdr'; 2 | 3 | export class Uint256 extends LargeInt { 4 | /** 5 | * Construct an unsigned 256-bit integer that can be XDR-encoded. 6 | * 7 | * @param {Array} args - one or more slices to encode 8 | * in big-endian format (i.e. earlier elements are higher bits) 9 | */ 10 | constructor(...args) { 11 | super(args); 12 | } 13 | 14 | get unsigned() { 15 | return true; 16 | } 17 | 18 | get size() { 19 | return 256; 20 | } 21 | } 22 | 23 | Uint256.defineIntBoundaries(); 24 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es2020", 5 | "module": "commonjs", 6 | "strict": true, 7 | "allowJs": true, 8 | "resolveJsonModule": true, 9 | "outDir": "./dist", 10 | "rootDir": "./src", 11 | "experimentalDecorators": true, 12 | "esModuleInterop": true, 13 | "skipLibCheck": true, 14 | "forceConsistentCasingInFileNames": true 15 | }, 16 | "include": [ 17 | "src/**/*.ts", 18 | "src/**/*.js", 19 | "src/**/*.json" 20 | ], 21 | "exclude": [ 22 | "**/node_modules" 23 | ] 24 | } -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/osmosis/aminotypes.ts: -------------------------------------------------------------------------------- 1 | import {GammAminoConverters} from "./gamm/v1beta1/aminotypes"; 2 | import {PoolManagerAminoConverter} from "./poolmanager/v1beta1/tx.amino"; 3 | import {LockupAminoConverter} from "./lockup/tx.amino"; 4 | import {SuperfluidAminoConverter} from "./superfluid/tx.amino"; 5 | import {TokenFactoryAminoConverter} from "./tokenfactory/v1beta1/tx.amino"; 6 | 7 | export const OsmosisAminoConverters = { 8 | ...GammAminoConverters, 9 | ...LockupAminoConverter, 10 | ...PoolManagerAminoConverter, 11 | ...SuperfluidAminoConverter, 12 | ...TokenFactoryAminoConverter 13 | } 14 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/api/index.ts: -------------------------------------------------------------------------------- 1 | import {randomBytes} from "crypto"; 2 | 3 | export {signMultiTransaction} from './transaction' 4 | export {buildNftTransferPayload, buildNotcoinVoucherExchange} from './nfts' 5 | 6 | export function generateQueryId() { 7 | return bigintRandom(8); 8 | } 9 | 10 | export function bigintRandom(bytes: number) { 11 | let value = BigInt(0); 12 | for (const randomNumber of randomBytes(bytes)) { 13 | const randomBigInt = BigInt(randomNumber); 14 | // eslint-disable-next-line no-bitwise 15 | value = (value << BigInt(8)) + randomBigInt; 16 | } 17 | return value; 18 | } -------------------------------------------------------------------------------- /bu-packages/coin-near/src/enums.ts: -------------------------------------------------------------------------------- 1 | /** @hidden @module */ 2 | export abstract class Enum { 3 | enum: string; 4 | 5 | constructor(properties: any) { 6 | if (Object.keys(properties).length !== 1) { 7 | throw new Error('Enum can only take single value'); 8 | } 9 | Object.keys(properties).map((key: string) => { 10 | (this as any)[key] = properties[key]; 11 | this.enum = key; 12 | }); 13 | } 14 | } 15 | 16 | export abstract class Assignable { 17 | constructor(properties: any) { 18 | Object.keys(properties).map((key: any) => { 19 | (this as any)[key] = properties[key]; 20 | }); 21 | } 22 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2020", 5 | "lib": [ 6 | "ES2020", 7 | "es7", 8 | "es6", 9 | "dom" 10 | ], 11 | "module": "commonjs", 12 | "moduleResolution": "node16", 13 | "declaration": true, 14 | "outDir": "dist", 15 | "downlevelIteration": true, 16 | "esModuleInterop": true, 17 | "forceConsistentCasingInFileNames": true, 18 | "strict": true, 19 | "skipLibCheck": true 20 | }, 21 | "include": [ 22 | "src/**/*" 23 | ], 24 | "exclude": [ 25 | "**/node_modules" 26 | ] 27 | } -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/bcs/hex.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | export function fromHEX(hexStr: string): Uint8Array { 5 | // @ts-ignore 6 | let intArr = hexStr 7 | .replace('0x', '') 8 | .match(/.{1,2}/g) 9 | .map(byte => parseInt(byte, 16)); 10 | 11 | if (intArr === null) { 12 | throw new Error(`Unable to parse HEX: ${hexStr}`); 13 | } 14 | 15 | return Uint8Array.from(intArr); 16 | } 17 | 18 | export function toHEX(bytes: Uint8Array): string { 19 | return bytes.reduce( 20 | (str, byte) => str + byte.toString(16).padStart(2, '0'), 21 | '' 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto/primitives/pbkdf2_sha512.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { pbkdf2_sha512 as internal } from '../../ton-crypto-primitives/node'; 10 | // import { pbkdf2_sha512 as internal } from '../../ton-crypto-primitives/browser'; 11 | 12 | export function pbkdf2_sha512(key: string | Buffer, salt: string | Buffer, iterations: number, keyLen: number): Promise { 13 | return internal(key, salt, iterations, keyLen); 14 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/utils/apiEndpoints.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | export enum Network { 4 | MAINNET = "mainnet", 5 | TESTNET = "testnet", 6 | DEVNET = "devnet", 7 | LOCAL = "local", 8 | CUSTOM = "custom", 9 | } 10 | 11 | export const NetworkToChainId: Record = { 12 | mainnet: 1, 13 | testnet: 2, 14 | }; 15 | 16 | export const NetworkToNetworkName: Record = { 17 | mainnet: Network.MAINNET, 18 | testnet: Network.TESTNET, 19 | devnet: Network.DEVNET, 20 | local: Network.LOCAL, 21 | custom: Network.CUSTOM, 22 | }; 23 | -------------------------------------------------------------------------------- /bu-packages/coin-nostrassets/src/keys.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Author:https://github.com/nbd-wtf/nostr-tools 3 | * */ 4 | import { generatePrivateKey, getPublicKey } from './keys' 5 | 6 | test('private key generation', () => { 7 | expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/) 8 | }) 9 | 10 | test('public key generation', () => { 11 | expect(getPublicKey(generatePrivateKey())).toMatch(/[a-f0-9]{64}/) 12 | }) 13 | 14 | test('public key from private key deterministic', () => { 15 | let sk = generatePrivateKey() 16 | let pk = getPublicKey(sk) 17 | 18 | for (let i = 0; i < 5; i++) { 19 | expect(getPublicKey(sk)).toEqual(pk) 20 | } 21 | }) 22 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/c32check/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Jude Nelson 5 | * 6 | * https://github.com/stacks-network/c32check/blob/master/LICENSE 7 | * */ 8 | import { c32encode, c32decode, c32normalize } from './encoding'; 9 | 10 | import { c32checkEncode, c32checkDecode } from './checksum'; 11 | 12 | import { c32address, c32addressDecode, c32ToB58, b58ToC32, versions } from './address'; 13 | 14 | export { 15 | c32encode, 16 | c32decode, 17 | c32checkEncode, 18 | c32checkDecode, 19 | c32address, 20 | c32addressDecode, 21 | c32normalize, 22 | versions, 23 | c32ToB58, 24 | b58ToC32, 25 | }; 26 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/api/jsonrpc/index.ts: -------------------------------------------------------------------------------- 1 | export type RequestBody = { 2 | id: number | string; 3 | jsonrpc: '2.0'; 4 | method: string; 5 | params?: {}; 6 | }; 7 | 8 | export type ResponseBody = { 9 | id: number | string; 10 | jsonrpc: '2.0'; 11 | } & (SuccessResponseBody | ErrorResponseBody); 12 | 13 | export type SuccessResponseBody = { 14 | result: unknown; 15 | }; 16 | 17 | export type ErrorResponseBody = { 18 | error: Error; 19 | }; 20 | 21 | export type Error = { 22 | code: number; 23 | message: string; 24 | data?: unknown; 25 | }; 26 | 27 | export type WebSocketEvent = Omit & { params: {} }; 28 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/helper.ts: -------------------------------------------------------------------------------- 1 | export function isHexString(value: string, length?: number) { 2 | if (!value.match(/^0x[0-9A-Fa-f]*$/)) { 3 | return false; 4 | } 5 | 6 | return !(length && value.length !== 2 + 2 * length); 7 | } 8 | 9 | export function validateHexString(value: string) { 10 | 11 | if (!value) { 12 | return false; 13 | } 14 | const hexStr = value.toLowerCase().startsWith("0x") ? value.substring(2).toLowerCase() : value.toLowerCase(); 15 | if(hexStr.length === 0 || hexStr.length % 2 !== 0) { 16 | return false; 17 | } 18 | if (!hexStr.match(/^[0-9A-Fa-f]*$/)) { 19 | return false; 20 | } 21 | return true 22 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/buffer-layout/utils/base.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `buffer-layout-utils`, thanks for their work 3 | * https://github.com/solana-labs/buffer-layout-utils/tree/master/src 4 | */ 5 | import { Layout } from '../layout'; 6 | 7 | export interface EncodeDecode { 8 | decode(buffer: Buffer, offset?: number): T; 9 | encode(src: T, buffer: Buffer, offset?: number): number; 10 | } 11 | 12 | export const encodeDecode = (layout: Layout): EncodeDecode => { 13 | const decode = layout.decode.bind(layout); 14 | const encode = layout.encode.bind(layout); 15 | return { decode, encode }; 16 | }; 17 | -------------------------------------------------------------------------------- /examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/lib/base/helper.ts: -------------------------------------------------------------------------------- 1 | export function isHexString(value: string, length?: number) { 2 | if (!value.match(/^0x[0-9A-Fa-f]*$/)) { 3 | return false; 4 | } 5 | 6 | return !(length && value.length !== 2 + 2 * length); 7 | } 8 | 9 | export function validateHexString(value: string) { 10 | 11 | if (!value) { 12 | return false; 13 | } 14 | const hexStr = value.toLowerCase().startsWith("0x") ? value.substring(2).toLowerCase() : value.toLowerCase(); 15 | if(hexStr.length === 0 || hexStr.length % 2 !== 0) { 16 | return false; 17 | } 18 | if (!hexStr.match(/^[0-9A-Fa-f]*$/)) { 19 | return false; 20 | } 21 | return true 22 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/contract/Contract.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Address } from "../address/Address"; 10 | import { Cell } from "../boc/Cell"; 11 | import { StateInit } from "../types/StateInit"; 12 | import { Maybe } from "../utils/maybe"; 13 | import { ContractABI } from "./ContractABI"; 14 | 15 | export interface Contract { 16 | readonly address: Address; 17 | readonly init?: Maybe; 18 | readonly abi?: Maybe; 19 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/address/contractAddress.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { beginCell } from "../boc/Builder"; 10 | import { StateInit, storeStateInit } from "../types/StateInit"; 11 | import { Address } from "./Address"; 12 | 13 | export function contractAddress(workchain: number, init: StateInit) { 14 | let hash = beginCell() 15 | .store(storeStateInit(init)) 16 | .endCell() 17 | .hash(); 18 | return new Address(workchain, hash); 19 | } -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/types/faucet.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { array, nullable, number, object, Infer, string } from 'superstruct'; 5 | import { TransactionDigest, ObjectId } from './common'; 6 | 7 | export const FaucetCoinInfo = object({ 8 | amount: number(), 9 | id: ObjectId, 10 | transferTxDigest: TransactionDigest, 11 | }); 12 | 13 | export type FaucetCoinInfo = Infer; 14 | 15 | export const FaucetResponse = object({ 16 | transferredGasObjects: array(FaucetCoinInfo), 17 | error: nullable(string()), 18 | }); 19 | 20 | export type FaucetResponse = Infer; 21 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-ton:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.3](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-ton:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | 19 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2024-08-15) 20 | 21 | ### Feature 22 | 23 | - **coin-ton:** support ton ([1.0.1](https://github.com/okx/js-wallet-sdk)) 24 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/contract.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CAT20State, 3 | GuardConstState, 4 | OpenMinterState, 5 | OpenMinterV2State, 6 | ProtocolState 7 | } from '@cat-protocol/cat-smartcontracts'; 8 | import {UTXO} from 'scrypt-ts'; 9 | 10 | export interface ContractState { 11 | protocolState: ProtocolState; 12 | 13 | data: T; 14 | } 15 | 16 | export interface Contract { 17 | utxo: UTXO; 18 | state: ContractState; 19 | } 20 | 21 | export type OpenMinterContract = Contract; 22 | 23 | export type TokenContract = Contract; 24 | 25 | export type GuardContract = Contract; 26 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/common/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | export enum ChainID { 9 | Testnet = 0x80000000, 10 | Mainnet = 0x00000001, 11 | } 12 | 13 | export enum TransactionVersion { 14 | Mainnet = 0x00, 15 | Testnet = 0x80, 16 | } 17 | 18 | /** 19 | * @ignore 20 | */ 21 | export const PRIVATE_KEY_COMPRESSED_LENGTH = 33; 22 | 23 | /** 24 | * @ignore 25 | */ 26 | export const PRIVATE_KEY_UNCOMPRESSED_LENGTH = 32; 27 | 28 | /** 29 | * @ignore 30 | */ 31 | export const BLOCKSTACK_DEFAULT_GAIA_HUB_URL = 'https://hub.blockstack.org'; -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/calldata/parser/interface.ts: -------------------------------------------------------------------------------- 1 | import { Abi, FunctionAbi } from '../../../types'; 2 | 3 | export abstract class AbiParserInterface { 4 | /** 5 | * Helper to calculate inputs length from abi 6 | * @param abiMethod FunctionAbi 7 | * @return number 8 | */ 9 | public abstract methodInputsLength(abiMethod: FunctionAbi): number; 10 | 11 | /** 12 | * 13 | * @param name string 14 | * @return FunctionAbi | undefined 15 | */ 16 | public abstract getMethod(name: string): FunctionAbi | undefined; 17 | 18 | /** 19 | * Return Abi in legacy format 20 | * @return Abi 21 | */ 22 | public abstract getLegacyFormat(): Abi; 23 | } 24 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/aptos_types/index.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | export * from "./account_address"; 10 | export * from "./authenticator"; 11 | export * from "./transaction"; 12 | export * from "./type_tag"; 13 | export * from "./identifier"; 14 | export * from "./ed25519"; 15 | export * from "./multi_ed25519"; 16 | export * from "./authentication_key"; 17 | 18 | // export type SigningMessage = Buffer; 19 | export type SigningMessage = Uint8Array; 20 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `bitcoinjs`, thanks for their work 3 | * https://github.com/bitcoinjs/bitcoinjs-lib 4 | */ 5 | import * as address from './address'; 6 | import * as crypto from './crypto'; 7 | import * as networks from './networks'; 8 | import * as payments from './payments'; 9 | import * as script from './script'; 10 | import * as bip0322 from './bip0322'; 11 | import * as psbt from './psbt'; 12 | 13 | export { address, crypto, networks, payments, script, bip0322, psbt }; 14 | export { Transaction } from './transaction'; 15 | export { Network } from './networks'; 16 | export { BufferWriter } from './bufferutils'; 17 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/signers/signer.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { SerializedSignature } from '../cryptography/signature'; 5 | 6 | /////////////////////////////// 7 | // Exported Types 8 | 9 | /////////////////////////////// 10 | // Exported Abstracts 11 | /** 12 | * Serializes a transaction to a string that can be signed by a `Signer`. 13 | */ 14 | export interface Signer { 15 | // Returns the checksum address 16 | getAddress(): Promise; 17 | 18 | /** 19 | * Returns the signature for the data and the public key of the signer 20 | */ 21 | signData(data: Uint8Array): Promise; 22 | } 23 | -------------------------------------------------------------------------------- /bu-packages/coin-near/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | 7 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 8 | 9 | ### New Features 10 | 11 | - **coin-near:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 12 | 13 | 14 | # [1.0.4](https://github.com/okx/js-wallet-sdk) (2024-08-20) 15 | 16 | ### Fix 17 | 18 | - **coin-near:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 19 | 20 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2024-4-9) 21 | 22 | ### New Feature 23 | 24 | - **coin-near:** support near dapp txs ([1.0.1](https://github.com/okx/js-wallet-sdk)) 25 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/patches/js-sha256+0.9.0.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/js-sha256/src/sha256.js b/node_modules/js-sha256/src/sha256.js 2 | index 14bcf45..6541f8a 100644 3 | --- a/node_modules/js-sha256/src/sha256.js 4 | +++ b/node_modules/js-sha256/src/sha256.js 5 | @@ -80,8 +80,8 @@ 6 | }; 7 | 8 | var nodeWrap = function (method, is224) { 9 | - var crypto = eval("require('crypto')"); 10 | - var Buffer = eval("require('buffer').Buffer"); 11 | + // var crypto = eval("require('crypto')"); 12 | + // var Buffer = eval("require('buffer').Buffer"); 13 | var algorithm = is224 ? 'sha224' : 'sha256'; 14 | var nodeMethod = function (message) { 15 | if (typeof message === 'string') { 16 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./common"; 2 | export * from "./currency"; 3 | export * from "./error"; 4 | export * from "./wallet"; 5 | export * from "./basic" 6 | 7 | // hash/codec implemnt such as sha256/base58/base64/hex/bech32. 8 | export * as base from "./base" 9 | 10 | // abi 11 | export * as abi from "./abi" 12 | 13 | export * as math from "./math" 14 | 15 | import BN from "bn.js" 16 | export { BN } 17 | 18 | import BigNumber from "bignumber.js"; 19 | export { BigNumber } 20 | 21 | const typeforce = require('typeforce'); 22 | export { typeforce } 23 | 24 | export * as protobuf from "protobufjs"; 25 | export * as _m0 from "protobufjs/minimal"; 26 | 27 | import Long from "long"; 28 | export {Long} -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node/hmac_sha512.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import crypto from 'crypto'; 10 | 11 | export async function hmac_sha512(key: string | Buffer, data: string | Buffer): Promise { 12 | let keyBuffer: Buffer = typeof key === 'string' ? Buffer.from(key, 'utf-8') : key; 13 | let dataBuffer: Buffer = typeof data === 'string' ? Buffer.from(data, 'utf-8') : data; 14 | return crypto.createHmac('sha512', keyBuffer) 15 | .update(dataBuffer) 16 | .digest(); 17 | } -------------------------------------------------------------------------------- /bu-packages/coin-tron/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-tron:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.4](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-tron:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | 19 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2024-02-22) 20 | 21 | ### Feature 22 | 23 | - **coin-tron:** support tron v2 signMessage and verifySignature ([](https://github.com/okx/js-wallet-sdk)) 24 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/cat20Enum.ts: -------------------------------------------------------------------------------- 1 | export enum CatAddressType { 2 | P2WPKH = 'p2wpkh', 3 | P2TR = 'p2tr', 4 | } 5 | 6 | export enum SupportedNetwork { 7 | btcSignet = 'btc-signet', 8 | fractalMainnet = 'fractal-mainnet', 9 | fractalTestnet = 'fractal-testnet' 10 | } 11 | 12 | 13 | export enum Postage { 14 | METADATA_POSTAGE = 546, 15 | GUARD_POSTAGE = 332, 16 | MINTER_POSTAGE = 331, 17 | TOKEN_POSTAGE = 330, 18 | } 19 | 20 | export const CHANGE_MIN_POSTAGE = 546; 21 | 22 | export enum MinterType { 23 | OPEN_MINTER_V1 = '21cbd2e538f2b6cc40ee180e174f1e25', 24 | OPEN_MINTER_V2 = 'a6c2e92d74a23c07bb6220b676c6cb9b', 25 | UNKOWN_MINTER = 'unkown_minter', 26 | } 27 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-stacks:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.3](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-stacks:** upgrading dependencies ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2024-1-2) 19 | 20 | ### Bug Fix 21 | 22 | - **coin-stacks:** compatible with private key signatures starting with 0x ([73](https://github.com/okx/js-wallet-sdk/pull/73)) 23 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-stellar', 5 | moduleFileExtensions: ['ts', 'js', 'json'], 6 | transform: { 7 | '^.+\\.ts$': ['ts-jest', { 8 | tsconfig: 'tsconfig.json', 9 | }], 10 | '^.*/coin-stellar/src/lib/.*\\.js$': ['ts-jest', { 11 | tsconfig: 'tsconfig.json', 12 | }], 13 | // '^.+\\.js$': 'babel-jest' // If you need to transform JS files as well, you can use Babel or other JS transpilers 14 | }, 15 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)$', // Match .test.ts, .test.js, .spec.ts and .spec.js files 16 | }; 17 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 6 | 7 | ### New Features 8 | 9 | - **coin-solana:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 10 | 11 | 12 | # [1.0.4](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-solana:** upgrading dependencies ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | # [1.0.3] (2024-06-19) 19 | 20 | ### fix 21 | 22 | - **coin-solana:** support mpl transfer and dynamic fee 23 | 24 | # [1.0.1] (2024-03-21) 25 | 26 | ### Feature 27 | 28 | - **coin-solana:** support token2022 and priority fee 29 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto-primitives/node/pbkdf2_sha512.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import crypto from 'crypto'; 10 | 11 | export function pbkdf2_sha512(key: string | Buffer, salt: string | Buffer, iterations: number, keyLen: number): Promise { 12 | return new Promise((resolve, reject) => crypto.pbkdf2(key, salt, iterations, keyLen, 'sha512', (error, derivedKey) => { 13 | if (error) { 14 | reject(error); 15 | } else { 16 | resolve(derivedKey); 17 | } 18 | })); 19 | } -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": true, 4 | "endOfLine": "lf", 5 | "htmlWhitespaceSensitivity": "css", 6 | "insertPragma": false, 7 | "singleAttributePerLine": false, 8 | "bracketSameLine": false, 9 | "jsxBracketSameLine": false, 10 | "jsxSingleQuote": false, 11 | "printWidth": 80, 12 | "proseWrap": "preserve", 13 | "quoteProps": "as-needed", 14 | "requirePragma": false, 15 | "semi": true, 16 | "singleQuote": true, 17 | "tabWidth": 2, 18 | "trailingComma": "es5", 19 | "useTabs": false, 20 | "embeddedLanguageFormatting": "auto", 21 | "vueIndentScriptAndStyle": false, 22 | "experimentalTernaries": false, 23 | "parser": "typescript" 24 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/aptos_types/identifier.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | import { Deserializer, Serializer } from "../bcs"; 10 | 11 | export class Identifier { 12 | constructor(public value: string) {} 13 | 14 | public serialize(serializer: Serializer): void { 15 | serializer.serializeStr(this.value); 16 | } 17 | 18 | static deserialize(deserializer: Deserializer): Identifier { 19 | const value = deserializer.deserializeStr(); 20 | return new Identifier(value); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/encryption/cryptoRandom.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | import { base } from '@okxweb3/coin-base'; 9 | 10 | /** 11 | * Reexports @noble/secp256k1's randombytes 12 | * Generates bytes with random bytes of given length 13 | * @param bytesLength an optional bytes length, default `32` bytes 14 | * @return {Uint8Array} random bytes 15 | */ 16 | export const randomBytes = (bytesLength: number = 32): Uint8Array => base.randomBytes(bytesLength); 17 | 18 | /** Optional function to generate cryptographically secure random bytes */ 19 | export type GetRandomBytes = (count: number) => Uint8Array; 20 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/api/aptosConfig.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | import {Network} from "../utils/apiEndpoints"; 4 | import {AptosSettings, MoveModuleBytecode} from "../types"; 5 | 6 | /** 7 | * This class holds the config information for the SDK client instance. 8 | */ 9 | export class AptosConfig { 10 | /** The Network that this SDK is associated with. Defaults to DEVNET */ 11 | readonly network: Network; 12 | 13 | readonly moveModule?: string; 14 | readonly module?:MoveModuleBytecode; 15 | 16 | constructor(settings?: AptosSettings) { 17 | this.network = settings?.network ?? Network.DEVNET; 18 | this.moveModule = settings?.moveModule; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated 4 | */ 5 | 6 | import { PublicKey } from '../../web3'; 7 | export * from './instructions'; 8 | export * from './types'; 9 | 10 | /** 11 | * Program address 12 | * 13 | * @category constants 14 | * @category generated 15 | */ 16 | export const PROGRAM_ADDRESS = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'; 17 | 18 | /** 19 | * Program public key 20 | * 21 | * @category constants 22 | * @category generated 23 | */ 24 | export const PROGRAM_ID = new PublicKey(PROGRAM_ADDRESS); 25 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/crypto/privateKey.ts: -------------------------------------------------------------------------------- 1 | import { HexInput } from "../../types"; 2 | import { PublicKey } from "./publicKey"; 3 | import { Signature } from "./signature"; 4 | 5 | /** 6 | * An abstract representation of a private key. 7 | * It is associated to a signature scheme and provides signing capabilities. 8 | */ 9 | export interface PrivateKey { 10 | /** 11 | * Sign the given message with the private key. 12 | * @param message in HexInput format 13 | */ 14 | sign(message: HexInput): Signature; 15 | 16 | /** 17 | * Derive the public key associated with the private key 18 | */ 19 | publicKey(): PublicKey; 20 | 21 | /** 22 | * Get the private key in bytes (Uint8Array). 23 | */ 24 | toUint8Array(): Uint8Array; 25 | } 26 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/cryptography/hash.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import {base} from "@okxweb3/coin-base"; 5 | 6 | /** 7 | * Generates a Blake2b hash of typed data as a base64 string. 8 | * 9 | * @param typeTag type tag (e.g. TransactionData, SenderSignedData) 10 | * @param data data to hash 11 | */ 12 | export function hashTypedData(typeTag: string, data: Uint8Array): Uint8Array { 13 | const typeTagBytes = Array.from(`${typeTag}::`).map((e) => e.charCodeAt(0)); 14 | 15 | const dataWithTag = new Uint8Array(typeTagBytes.length + data.length); 16 | dataWithTag.set(typeTagBytes); 17 | dataWithTag.set(data, typeTagBytes.length); 18 | 19 | return base.blake2b(dataWithTag, { dkLen: 32 }); 20 | } 21 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/bcs/consts.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from "../types"; 5 | 6 | // Upper bound values for uint8, uint16, uint64 etc. These are all derived as 7 | // 2^N - 1, where N is the number of bits in the type. 8 | export const MAX_U8_NUMBER: Uint8 = 255; 9 | export const MAX_U16_NUMBER: Uint16 = 65535; 10 | export const MAX_U32_NUMBER: Uint32 = 4294967295; 11 | export const MAX_U64_BIG_INT: Uint64 = 18446744073709551615n; 12 | export const MAX_U128_BIG_INT: Uint128 = 340282366920938463463374607431768211455n; 13 | export const MAX_U256_BIG_INT: Uint256 = 14 | 115792089237316195423570985008687907853269984665640564039457584007913129639935n; 15 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/assert.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Asserts that the given condition is true, otherwise throws an error with an optional message. 3 | * @param {boolean} condition - The condition to check. 4 | * @param {string} [message] - The optional message to include in the error. 5 | * @throws {Error} Throws an error if the condition is false. 6 | * @example 7 | * ```typescript 8 | * const address = '0xa7ee790591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf'; 9 | * assert(/^(0x)?[0-9a-fA-F]{64}$/.test(address), 'Invalid address format'); 10 | * ``` 11 | */ 12 | export default function assert(condition: boolean, message?: string): asserts condition { 13 | if (!condition) { 14 | throw new Error(message || 'Assertion failure'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/utils.ts: -------------------------------------------------------------------------------- 1 | export function convertWithDecimals(numStr: string, decimals: number) { 2 | if (numStr == "0") { 3 | return numStr 4 | } 5 | if (!isPositiveIntegerNoZero(numStr)) { 6 | throw new RangeError("Number should be a positive integer"); 7 | } 8 | if (numStr.length <= decimals) { 9 | numStr = addLeadingZeros(numStr, decimals + 1); 10 | } 11 | let position = numStr.length - decimals 12 | return numStr.slice(0, position) + "." + numStr.slice(position); 13 | } 14 | 15 | function addLeadingZeros(str: string | number, length: number): string { 16 | return String(str).padStart(length, "0"); 17 | } 18 | 19 | function isPositiveIntegerNoZero(str: string): boolean { 20 | return /^[1-9]\d*$/.test(str); 21 | } -------------------------------------------------------------------------------- /bu-packages/coin-base/patches/@protobufjs+inquire+1.1.0.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/@protobufjs/inquire/index.js b/node_modules/@protobufjs/inquire/index.js 2 | index 33778b5..984d445 100644 3 | --- a/node_modules/@protobufjs/inquire/index.js 4 | +++ b/node_modules/@protobufjs/inquire/index.js 5 | @@ -9,7 +9,8 @@ module.exports = inquire; 6 | */ 7 | function inquire(moduleName) { 8 | try { 9 | - var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval 10 | + // var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval 11 | + var mod = require(moduleName); 12 | if (mod && (mod.length || Object.keys(mod).length)) 13 | return mod; 14 | } catch (e) {} // eslint-disable-line no-empty 15 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/fee-calculator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src 4 | */ 5 | 6 | import * as BufferLayout from '../buffer-layout'; 7 | 8 | /** 9 | * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11 10 | * 11 | * @internal 12 | */ 13 | export const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature'); 14 | 15 | /** 16 | * Calculator for transaction fees. 17 | * 18 | * @deprecated Deprecated since Solana v1.8.0. 19 | */ 20 | export interface FeeCalculator { 21 | /** Cost in lamports to validate a signature. */ 22 | lamportsPerSignature: number; 23 | } 24 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/payments/lazy.ts: -------------------------------------------------------------------------------- 1 | export function prop(object: {}, name: string, f: () => any): void { 2 | Object.defineProperty(object, name, { 3 | configurable: true, 4 | enumerable: true, 5 | get(): any { 6 | const _value = f.call(this); 7 | this[name] = _value; 8 | return _value; 9 | }, 10 | set(_value: any): void { 11 | Object.defineProperty(this, name, { 12 | configurable: true, 13 | enumerable: true, 14 | value: _value, 15 | writable: true, 16 | }); 17 | }, 18 | }); 19 | } 20 | 21 | export function value(f: () => T): () => T { 22 | let _value: T; 23 | return (): T => { 24 | if (_value !== undefined) return _value; 25 | _value = f(); 26 | return _value; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/metadata.ts: -------------------------------------------------------------------------------- 1 | export interface TokenInfo { 2 | name: string; 3 | symbol: string; 4 | decimals: number; 5 | minterMd5: string; 6 | } 7 | 8 | const INT32_MAX = 2147483647n; 9 | 10 | export const MAX_TOTAL_SUPPLY = INT32_MAX; 11 | 12 | export interface ClosedMinterTokenInfo extends TokenInfo { 13 | } 14 | 15 | export interface OpenMinterTokenInfo extends TokenInfo { 16 | max: bigint; 17 | limit: bigint; 18 | premine: bigint; 19 | } 20 | 21 | export interface TokenMetadata { 22 | info: TokenInfo; 23 | tokenId: string; 24 | /** token p2tr address */ 25 | tokenAddr: string; 26 | /** minter p2tr address */ 27 | minterAddr: string; 28 | genesisTxid: string; 29 | revealTxid: string; 30 | timestamp: number; 31 | } 32 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/network.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains passphrases for common networks: 3 | * * `Networks.PUBLIC`: `Public Global Stellar Network ; September 2015` 4 | * * `Networks.TESTNET`: `Test SDF Network ; September 2015` 5 | * * `Networks.FUTURENET`: `Test SDF Future Network ; October 2022` 6 | * * `Networks.STANDALONE`: `Standalone Network ; February 2017` 7 | * 8 | * @type {{PUBLIC: string, TESTNET: string, FUTURENET: string, STANDALONE: string }} 9 | */ 10 | export const Networks = { 11 | PUBLIC: 'Public Global Stellar Network ; September 2015', 12 | TESTNET: 'Test SDF Network ; September 2015', 13 | FUTURENET: 'Test SDF Future Network ; October 2022', 14 | SANDBOX: 'Local Sandbox Stellar Network ; September 2022', 15 | STANDALONE: 'Standalone Network ; February 2017' 16 | }; 17 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/transaction_builder/bcs/consts.ts: -------------------------------------------------------------------------------- 1 | /*** 2 | * Copyright © Aptos Foundation 3 | *SPDX-License-Identifier: Apache-2.0 4 | * 5 | * https://raw.githubusercontent.com/aptos-labs/aptos-core/097ea73b4a78c0166f22a269f27e514dc895afb4/ecosystem/typescript/sdk/LICENSE 6 | * 7 | * */ 8 | 9 | import {Uint128, Uint16, Uint256, Uint32, Uint64, Uint8} from "./types"; 10 | 11 | // Upper bound values for uint8, uint16, uint64 and uint128 12 | export const MAX_U8_NUMBER: Uint8 = 2 ** 8 - 1; 13 | export const MAX_U16_NUMBER: Uint16 = 2 ** 16 - 1; 14 | export const MAX_U32_NUMBER: Uint32 = 2 ** 32 - 1; 15 | export const MAX_U64_BIG_INT: Uint64 = BigInt(2 ** 64) - 1n; 16 | export const MAX_U128_BIG_INT: Uint128 = BigInt(2 ** 128) - 1n; 17 | export const MAX_U256_BIG_INT: Uint256 = BigInt(2 ** 256) - BigInt(1); -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/src/lib/sdk/ethereumjs-tx/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `ethereumjs/tx`, thanks for their work 3 | * https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx 4 | * Distributed under the Mozilla Public License Version 2.0 software license, see the accompanying 5 | * file LICENSE or https://opensource.org/license/mpl-2-0/. 6 | */ 7 | 8 | export { default as Transaction } from './legacyTransaction' 9 | export { default as AccessListEIP2930Transaction } from './eip2930Transaction' 10 | export { default as TransactionFactory } from './transactionFactory' 11 | export { default as FeeMarketEIP1559Transaction } from './eip1559Transaction' 12 | export { default as EOACodeEIP7702Transaction } from './eip7702Transaction' 13 | 14 | export * from './types' 15 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/LeafInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This code was GENERATED using the solita package. 3 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 4 | * 5 | * See: https://github.com/metaplex-foundation/solita 6 | */ 7 | 8 | import * as beet from '@metaplex-foundation/beet'; 9 | export type LeafInfo = { 10 | leaf: number[] /* size: 32 */; 11 | proof: number[] /* size: 32 */[]; 12 | }; 13 | 14 | /** 15 | * @category userTypes 16 | * @category generated 17 | */ 18 | export const leafInfoBeet = new beet.FixableBeetArgsStruct( 19 | [ 20 | ['leaf', beet.uniformFixedSizeArray(beet.u8, 32)], 21 | ['proof', beet.array(beet.uniformFixedSizeArray(beet.u8, 32))], 22 | ], 23 | 'LeafInfo', 24 | ); 25 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/dict/utils/findCommonPrefix.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export function findCommonPrefix(src: string[], startPos = 0) { 10 | 11 | // Corner cases 12 | if (src.length === 0) { 13 | return ''; 14 | } 15 | 16 | let r = src[0].slice(startPos); 17 | 18 | for (let i = 1; i < src.length; i++) { 19 | const s = src[i]; 20 | while (s.indexOf(r, startPos) !== startPos) { 21 | r = r.substring(0, r.length - 1); 22 | 23 | if (r === '') { 24 | return r; 25 | } 26 | } 27 | } 28 | 29 | return r; 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/operations/end_sponsoring_future_reserves.js: -------------------------------------------------------------------------------- 1 | import xdr from '../xdr'; 2 | 3 | /** 4 | * Create an "end sponsoring future reserves" operation. 5 | * @function 6 | * @alias Operation.endSponsoringFutureReserves 7 | * @param {object} opts Options object 8 | * @param {string} [opts.source] - The source account for the operation. Defaults to the transaction's source account. 9 | * @returns {xdr.Operation} xdr operation 10 | * 11 | * @example 12 | * const op = Operation.endSponsoringFutureReserves(); 13 | * 14 | */ 15 | export function endSponsoringFutureReserves(opts = {}) { 16 | const opAttributes = {}; 17 | opAttributes.body = xdr.OperationBody.endSponsoringFutureReserves(); 18 | this.setSourceAccount(opAttributes, opts); 19 | 20 | return new xdr.Operation(opAttributes); 21 | } 22 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/instances/chainId.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { Serializer, Serializable } from "../../bcs/serializer"; 5 | import { Deserializer } from "../../bcs/deserializer"; 6 | 7 | /** 8 | * Representation of a ChainId that can serialized and deserialized 9 | */ 10 | export class ChainId extends Serializable { 11 | public readonly chainId: number; 12 | 13 | constructor(chainId: number) { 14 | super(); 15 | this.chainId = chainId; 16 | } 17 | 18 | serialize(serializer: Serializer): void { 19 | serializer.serializeU8(this.chainId); 20 | } 21 | 22 | static deserialize(deserializer: Deserializer): ChainId { 23 | const chainId = deserializer.deserializeU8(); 24 | return new ChainId(chainId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/types/Pda.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `types`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/types 4 | */ 5 | import { Buffer } from 'buffer'; 6 | import { PublicKey, PublicKeyInitData } from '../../web3'; 7 | 8 | export class Pda extends PublicKey { 9 | /** The bump used to generate the PDA. */ 10 | public readonly bump: number; 11 | 12 | constructor(value: PublicKeyInitData, bump: number) { 13 | super(value); 14 | this.bump = bump; 15 | } 16 | 17 | static find(programId: PublicKey, seeds: Array): Pda { 18 | const [publicKey, bump] = PublicKey.findProgramAddressSync( 19 | seeds, 20 | programId 21 | ); 22 | 23 | return new Pda(publicKey, bump); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-crypto/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export { sha256, sha256_sync } from './primitives/sha256'; 10 | export { sha512, sha512_sync } from './primitives/sha512'; 11 | export { pbkdf2_sha512 } from './primitives/pbkdf2_sha512'; 12 | export { hmac_sha512 } from './primitives/hmac_sha512'; 13 | export { getSecureRandomBytes, getSecureRandomWords, getSecureRandomNumber } from './primitives/getSecureRandom'; 14 | export { KeyPair } from './primitives/nacl'; 15 | export { sealBox, openBox } from './primitives/nacl'; 16 | export { keyPairFromSeed, keyPairFromSecretKey, sign, signVerify } from './primitives/nacl'; 17 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "lib": [ 5 | "es2020" 6 | ], 7 | "moduleResolution": "node", 8 | "module": "CommonJS", 9 | "strict": true, 10 | "declaration": true, 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "resolveJsonModule": true, 14 | /* Additional Checks */ 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noFallthroughCasesInSwitch": true, 18 | /* Debugging Options */ 19 | "traceResolution": false, 20 | "listEmittedFiles": false, 21 | "listFiles": false, 22 | "pretty": false, 23 | "removeComments": true, 24 | "typeRoots": [ 25 | "node_modules/@types" 26 | ], 27 | "skipLibCheck": true 28 | }, 29 | "exclude": [ 30 | "**/node_modules" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/wallet-api/events.ts: -------------------------------------------------------------------------------- 1 | import type { ChainId } from '../api'; 2 | 3 | // Optimization on events 4 | export type AccountChangeEventHandler = (accounts?: string[]) => void; 5 | export type NetworkChangeEventHandler = (chainId?: ChainId, accounts?: string[]) => void; 6 | 7 | export interface WalletEventHandlers { 8 | accountsChanged: AccountChangeEventHandler; 9 | networkChanged: NetworkChangeEventHandler; 10 | } 11 | 12 | // TODO: Check with get-starknet team do we need it 13 | export type WalletEvents = { 14 | [E in keyof WalletEventHandlers]: { type: E; handler: WalletEventHandlers[E] }; 15 | }[keyof WalletEventHandlers]; 16 | 17 | export type WalletEventListener = ( 18 | event: E, 19 | handleEvent: WalletEventHandlers[E] 20 | ) => void; 21 | -------------------------------------------------------------------------------- /examples/src/components/SignedOutput.tsx: -------------------------------------------------------------------------------- 1 | import {Alert, AlertIcon, AlertTitle, Box} from "@chakra-ui/react"; 2 | import React from "react"; 3 | 4 | 5 | const SignedOutput: React.FC<{name: string, output: string}> = (props) => { 6 | return ( 7 | props.output ? 8 | 16 | 17 | 18 | {props.name}: 19 | {props.output} 20 | 21 | 22 | : 23 | ); 24 | }; 25 | export default SignedOutput -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/utf8.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/naming-convention */ 2 | // Global symbols in both browsers and Node.js since v11 3 | // https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder 4 | // https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder 5 | // https://nodejs.org/docs/latest-v12.x/api/util.html#util_class_util_textencoder 6 | // https://nodejs.org/docs/latest-v12.x/api/util.html#util_class_util_textdecoder 7 | // See https://github.com/microsoft/TypeScript/issues/31535 8 | declare const TextEncoder: any; 9 | declare const TextDecoder: any; 10 | 11 | export function toUtf8(str: string): Uint8Array { 12 | return new TextEncoder().encode(str); 13 | } 14 | 15 | export function fromUtf8(data: Uint8Array): string { 16 | return new TextDecoder("utf-8", { fatal: true }).decode(data); 17 | } 18 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/address/ExternalAddress.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import inspectSymbol from 'symbol.inspect'; 10 | export class ExternalAddress { 11 | 12 | static isAddress(src: any): src is ExternalAddress { 13 | return src instanceof ExternalAddress; 14 | } 15 | 16 | readonly value: bigint; 17 | readonly bits: number; 18 | 19 | constructor(value: bigint, bits: number) { 20 | this.value = value; 21 | this.bits = bits; 22 | } 23 | 24 | toString() { 25 | return `External<${this.bits}:${this.value}>`; 26 | } 27 | 28 | [inspectSymbol] = () => this.toString() 29 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/contract/Sender.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Address } from "../address/Address"; 10 | import { Cell } from "../boc/Cell"; 11 | import { SendMode } from "../types/SendMode"; 12 | import { StateInit } from "../types/StateInit"; 13 | import { Maybe } from "../utils/maybe"; 14 | 15 | export type SenderArguments = { 16 | value: bigint, 17 | to: Address, 18 | sendMode?: Maybe, 19 | bounce?: Maybe, 20 | init?: Maybe, 21 | body?: Maybe 22 | } 23 | 24 | export interface Sender { 25 | readonly address?: Address; 26 | send(args: SenderArguments): Promise; 27 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/types/PublicKey.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `types`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/types 4 | */ 5 | import { PublicKey, PublicKeyInitData } from '../../web3'; 6 | 7 | export { PublicKey } from '../../web3'; 8 | export type PublicKeyString = string; 9 | export type PublicKeyValues = 10 | | PublicKeyInitData 11 | | { publicKey: PublicKey } 12 | | { address: PublicKey }; 13 | 14 | export const toPublicKey = (value: PublicKeyValues): PublicKey => { 15 | if (typeof value === 'object' && 'publicKey' in value) { 16 | return value.publicKey; 17 | } 18 | 19 | if (typeof value === 'object' && 'address' in value) { 20 | return (value as { address: PublicKey }).address; 21 | } 22 | 23 | return new PublicKey(value); 24 | }; 25 | -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/transactions/clarity/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | /** 9 | * Type IDs corresponding to each of the Clarity value types as described here: 10 | * {@link https://github.com/blockstack/blockstack-core/blob/sip/sip-005/sip/sip-005-blocks-and-transactions.md#clarity-value-representation} 11 | */ 12 | export enum ClarityType { 13 | Int = 0x00, 14 | UInt = 0x01, 15 | Buffer = 0x02, 16 | BoolTrue = 0x03, 17 | BoolFalse = 0x04, 18 | PrincipalStandard = 0x05, 19 | PrincipalContract = 0x06, 20 | ResponseOk = 0x07, 21 | ResponseErr = 0x08, 22 | OptionalNone = 0x09, 23 | OptionalSome = 0x0a, 24 | List = 0x0b, 25 | Tuple = 0x0c, 26 | StringASCII = 0x0d, 27 | StringUTF8 = 0x0e, 28 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/contract/ComputeError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Maybe } from "../utils/maybe"; 10 | 11 | export class ComputeError extends Error { 12 | exitCode: number; 13 | debugLogs: string | null; 14 | logs: string | null; 15 | 16 | constructor(message: string, exitCode: number, opts?: { debugLogs?: Maybe, logs?: Maybe }) { 17 | super(message); 18 | this.exitCode = exitCode; 19 | this.debugLogs = opts && opts.debugLogs ? opts.debugLogs : null; 20 | this.logs = opts && opts.logs ? opts.logs : null; 21 | Object.setPrototypeOf(this, ComputeError.prototype); 22 | } 23 | } -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/bignumber-plus.ts: -------------------------------------------------------------------------------- 1 | import {BigNumber} from '../index'; 2 | 3 | import {check} from './precondtion'; 4 | 5 | const toBigIntHex = (value: BigNumber): string => { 6 | let hexStr = value.integerValue().toString(16); 7 | 8 | hexStr = '0x' + hexStr; 9 | return hexStr; 10 | }; 11 | 12 | const fromBigIntHex = (value: string): BigNumber => { 13 | check(value && value.startsWith('0x'), `Invalid hex string. value: ${value}`); 14 | return new BigNumber(value).integerValue(); 15 | }; 16 | 17 | const bigNumber2String = (value: BigNumber, base?: number): string => { 18 | return value.integerValue().toString(base); 19 | }; 20 | 21 | const string2BigNumber = (n: string | number, base?: number): BigNumber => { 22 | return new BigNumber(n, base); 23 | }; 24 | 25 | export {toBigIntHex, fromBigIntHex, bigNumber2String, string2BigNumber}; 26 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/cryptography/keypair.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { PublicKey } from './publickey'; 5 | import { SignatureScheme } from './signature'; 6 | 7 | export const PRIVATE_KEY_SIZE = 32; 8 | export const LEGACY_PRIVATE_KEY_SIZE = 64; 9 | 10 | export type ExportedKeypair = { 11 | schema: SignatureScheme; 12 | privateKey: string; 13 | }; 14 | 15 | /** 16 | * A keypair used for signing transactions. 17 | */ 18 | export interface Keypair { 19 | /** 20 | * The public key for this keypair 21 | */ 22 | getPublicKey(): PublicKey; 23 | 24 | /** 25 | * Return the signature for the data 26 | */ 27 | signData(data: Uint8Array): Uint8Array; 28 | 29 | /** 30 | * Get the key scheme of the keypair: Secp256k1 or ED25519 31 | */ 32 | getKeyScheme(): SignatureScheme; 33 | } 34 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/SeedsVec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | export type SeedsVec = { 15 | seeds: Uint8Array[]; 16 | }; 17 | 18 | /** 19 | * @category userTypes 20 | * @category generated 21 | */ 22 | export const seedsVecBeet = new beet.FixableBeetArgsStruct( 23 | [['seeds', beet.array(beet.bytes)]], 24 | 'SeedsVec', 25 | ); 26 | -------------------------------------------------------------------------------- /bu-packages/coin-kaia/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | ...require('../../jest.config.base.js'), 4 | displayName: 'coin-kaia', 5 | transform: { 6 | '^.+\\.(ts|tsx)$': 'ts-jest', 7 | '^.+\\.js$': 'babel-jest', // Transpile JS files 8 | }, 9 | transformIgnorePatterns: [ 10 | '/node_modules/(?!lodash-es|@kaiachain/ethers-ext)', // Force transpile these dependencies 11 | ], 12 | extensionsToTreatAsEsm: ['.ts', '.tsx'], // Specify these extensions to be treated as ESM 13 | moduleNameMapper: { 14 | '^@kaiachain/ethers-ext/src/v6$': '/node_modules/@kaiachain/ethers-ext/src/v6', 15 | '^@kaiachain/js-ext-core/util$': '/node_modules/@kaiachain/js-ext-core/util', 16 | '^@kaiachain/js-ext-core/ethers-v6$': '/node_modules/@kaiachain/js-ext-core/ethers-v6', 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/utils/crc16.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export function crc16(data: Buffer) { 10 | const poly = 0x1021; 11 | let reg = 0; 12 | const message = Buffer.alloc(data.length + 2); 13 | message.set(data); 14 | for (let byte of message) { 15 | let mask = 0x80; 16 | while (mask > 0) { 17 | reg <<= 1; 18 | if (byte & mask) { 19 | reg += 1; 20 | } 21 | mask >>= 1 22 | if (reg > 0xffff) { 23 | reg &= 0xffff; 24 | reg ^= poly; 25 | } 26 | } 27 | } 28 | return Buffer.from([Math.floor(reg / 256), reg % 256]); 29 | } -------------------------------------------------------------------------------- /examples/src/pages/Ton.tsx: -------------------------------------------------------------------------------- 1 | import {VStack} from "@chakra-ui/react"; 2 | import {useState} from "react"; 3 | import TonPrivateKey from "../components/TonPrivateKey"; 4 | import {TonWallet} from "@okxweb3/coin-ton"; 5 | import TonSignTx from "../components/TonSignTx"; 6 | import TonSignJettonTx from "../components/TonSignJettonTx"; 7 | 8 | 9 | export default function Ton() { 10 | const [privateKey, setPrivateKey] = useState("49c0722d56d6bac802bdf5c480a17c870d1d18bc4355d8344aa05390eb778280") 11 | const wallet = new TonWallet() 12 | 13 | return ( 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/core/crypto/utils.ts: -------------------------------------------------------------------------------- 1 | import { HexInput } from "../../types"; 2 | import {Hex} from "../hex"; 3 | 4 | /** 5 | * Helper function to convert a message to sign or to verify to a valid message input 6 | * 7 | * @param message a message as a string or Uint8Array 8 | * 9 | * @returns a valid HexInput - string or Uint8Array 10 | */ 11 | export const convertSigningMessage = (message: HexInput): HexInput => { 12 | // if message is of type string, verify it is a valid Hex string 13 | if (typeof message === "string") { 14 | const isValid = Hex.isValid(message); 15 | // If message is not a valid Hex string, convert it into a Buffer 16 | if (!isValid.valid) { 17 | return Buffer.from(message, "utf8"); 18 | } 19 | // If message is a valid Hex string, return it 20 | return message; 21 | } 22 | // message is a Uint8Array 23 | return message; 24 | }; 25 | -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/precondtion.ts: -------------------------------------------------------------------------------- 1 | type ErrorType = undefined | string | Error; 2 | 3 | const check = (statement: any, orError?: ErrorType) => { 4 | if (!statement) { 5 | orError = orError ? orError : 'Invalid statement'; 6 | orError = orError instanceof Error ? orError : new Error(orError); 7 | 8 | throw orError; 9 | } 10 | }; 11 | 12 | const checkIsDefined = (something?: T, orError?: ErrorType): T => { 13 | check( 14 | typeof something !== 'undefined', 15 | orError || 'Expect defined but actually undefined', 16 | ); 17 | return something as T; 18 | }; 19 | 20 | const checkIsUndefined = (something: any, orError?: ErrorType) => { 21 | check( 22 | typeof something === 'undefined', 23 | orError || `Expect undefined but actually ${something}`, 24 | ); 25 | }; 26 | 27 | export {check, checkIsDefined, checkIsUndefined}; 28 | -------------------------------------------------------------------------------- /examples/src/components/toast.tsx: -------------------------------------------------------------------------------- 1 | import {CreateToastFnReturn} from "@chakra-ui/react"; 2 | 3 | const capitalizeFirstLetter = (str: string): string => { 4 | if (str.length === 0) return str; // Handle empty string case 5 | return str.charAt(0).toUpperCase() + str.slice(1); 6 | }; 7 | export function successToast(toast: CreateToastFnReturn, title: string) { 8 | toast.closeAll() 9 | return toast({ 10 | title: capitalizeFirstLetter(title), 11 | status: 'success', 12 | duration: 5000, 13 | isClosable: true, 14 | position: "top-right" 15 | }) 16 | 17 | } 18 | export function errorToast(toast: CreateToastFnReturn, title: string) { 19 | toast.closeAll() 20 | return toast({ 21 | title: capitalizeFirstLetter(title), 22 | status: 'error', 23 | duration: 5000, 24 | isClosable: true, 25 | position: "top-right" 26 | }) 27 | } -------------------------------------------------------------------------------- /bu-packages/coin-kaspa/src/lib/validation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `Emilio Almansi`, thanks for their work 3 | * @license 4 | * https://github.com/ealmansi/cashaddrjs 5 | * Copyright (c) 2017-2020 Emilio Almansi 6 | * Distributed under the MIT software license, see the accompanying 7 | * file LICENSE or http://www.opensource.org/licenses/mit-license.php. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | /** 13 | * Validation utility. 14 | * 15 | * @module validation 16 | */ 17 | 18 | /** 19 | * Validates a given condition, throwing a {@link Error} if 20 | * the given condition does not hold. 21 | * 22 | * @static 23 | * @param {boolean} condition Condition to validate. 24 | * @param {string} message Error message in case the condition does not hold. 25 | */ 26 | export function validate(condition: any, message: string) { 27 | if (!condition) { 28 | throw new Error(message); 29 | } 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/plugins/nftModule/models/Metadata.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `nftModule`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/plugins/nftModule 4 | */ 5 | 6 | import { 7 | TokenStandard, 8 | } from '../../../mpl-token-metadata'; 9 | import { Option } from '../../../utils'; 10 | 11 | export const isNonFungible = (nftOrSft: { 12 | tokenStandard: Option; 13 | }): boolean => 14 | nftOrSft.tokenStandard === null || 15 | nftOrSft.tokenStandard === TokenStandard.NonFungible || 16 | nftOrSft.tokenStandard === TokenStandard.NonFungibleEdition || 17 | nftOrSft.tokenStandard === TokenStandard.ProgrammableNonFungible; 18 | 19 | export const isProgrammable = (nftOrSft: { 20 | tokenStandard: Option; 21 | }): boolean => nftOrSft.tokenStandard === TokenStandard.ProgrammableNonFungible; 22 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/spl/instructions/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-program-library`, thanks for their work 3 | * https://github.com/solana-labs/solana-program-library/tree/master/token/js/src/instructions 4 | */ 5 | 6 | /** Instructions defined by the program */ 7 | export enum TokenInstruction { 8 | InitializeMint = 0, 9 | InitializeAccount = 1, 10 | InitializeMultisig = 2, 11 | Transfer = 3, 12 | Approve = 4, 13 | Revoke = 5, 14 | SetAuthority = 6, 15 | MintTo = 7, 16 | Burn = 8, 17 | CloseAccount = 9, 18 | FreezeAccount = 10, 19 | ThawAccount = 11, 20 | TransferChecked = 12, 21 | ApproveChecked = 13, 22 | MintToChecked = 14, 23 | BurnChecked = 15, 24 | InitializeAccount2 = 16, 25 | SyncNative = 17, 26 | InitializeAccount3 = 18, 27 | InitializeMultisig2 = 19, 28 | InitializeMint2 = 20, 29 | } 30 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/utils/normalizeBundle.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { Deserializer, Serializable } from "../bcs"; 5 | 6 | export type DeserializableClass = { 7 | deserialize(deserializer: Deserializer): T; 8 | }; 9 | 10 | /** 11 | * Utility function that serializes and deserialize an object back into the same bundle as the sdk. 12 | * This is a workaround to have the `instanceof` operator work when input objects come from a different 13 | * bundle. 14 | * @param cls The class of the object to normalize 15 | * @param value the instance to normalize 16 | */ 17 | export function normalizeBundle(cls: DeserializableClass, value: T) { 18 | const serializedBytes = value.bcsToBytes(); 19 | const deserializer = new Deserializer(serializedBytes); 20 | return cls.deserialize(deserializer); 21 | } 22 | -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.1](https://github.com/okx/js-wallet-sdk)(2025-03-24) 7 | 8 | ### New Features 9 | 10 | - **coin-ethereum:** support EIP-7702 11 | 12 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 13 | 14 | ### New Features 15 | 16 | - **coin-ethereum:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 17 | - 18 | # [1.0.5](https://github.com/okx/js-wallet-sdk) (2024-08-20) 19 | 20 | ### Fix 21 | 22 | - **coin-ethereum:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 23 | 24 | 25 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2023-10-31) 26 | 27 | ### Bug Fixes 28 | 29 | - **coin-ethereum:** signMessage supports more data types ([ef53b09](https://github.com/okx/js-wallet-sdk/commit/ef53b095efd880b2b863e8780933754a39f78f10)) 30 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/web3/utils/shortvec-encoding.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `solana-web3.js`, thanks for their work 3 | * https://github.com/solana-labs/solana-web3.js/tree/master/packages/library-legacy/src/utils 4 | */ 5 | 6 | export function decodeLength(bytes: Array): number { 7 | let len = 0; 8 | let size = 0; 9 | for (;;) { 10 | let elem = bytes.shift() as number; 11 | len |= (elem & 0x7f) << (size * 7); 12 | size += 1; 13 | if ((elem & 0x80) === 0) { 14 | break; 15 | } 16 | } 17 | return len; 18 | } 19 | 20 | export function encodeLength(bytes: Array, len: number) { 21 | let rem_len = len; 22 | for (;;) { 23 | let elem = rem_len & 0x7f; 24 | rem_len >>= 7; 25 | if (rem_len == 0) { 26 | bytes.push(elem); 27 | break; 28 | } else { 29 | elem |= 0x80; 30 | bytes.push(elem); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoinjs-lib/bip174/converter/shared/checkPubkey.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `bitcoinjs`, thanks for their work 3 | * https://github.com/bitcoinjs/bitcoinjs-lib 4 | */ 5 | import { KeyValue } from '../../interfaces'; 6 | 7 | export function makeChecker( 8 | pubkeyTypes: number[], 9 | ): (keyVal: KeyValue) => Buffer | undefined { 10 | return checkPubkey; 11 | function checkPubkey(keyVal: KeyValue): Buffer | undefined { 12 | let pubkey: Buffer | undefined; 13 | if (pubkeyTypes.includes(keyVal.key[0])) { 14 | pubkey = keyVal.key.slice(1); 15 | if ( 16 | !(pubkey.length === 33 || pubkey.length === 65) || 17 | ![2, 3, 4].includes(pubkey[0]) 18 | ) { 19 | throw new Error( 20 | 'Format Error: invalid pubkey in key 0x' + keyVal.key.toString('hex'), 21 | ); 22 | } 23 | } 24 | return pubkey; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/bitcoincash/validation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `Emilio Almansi`, thanks for their work 3 | * @license 4 | * https://github.com/ealmansi/cashaddrjs 5 | * Copyright (c) 2017-2020 Emilio Almansi 6 | * Distributed under the MIT software license, see the accompanying 7 | * file LICENSE or http://www.opensource.org/licenses/mit-license.php. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | /** 13 | * Validation utility. 14 | * 15 | * @module validation 16 | */ 17 | 18 | /** 19 | * Validates a given condition, throwing a {@link ValidationError} if 20 | * the given condition does not hold. 21 | * 22 | * @static 23 | * @param {boolean} condition Condition to validate. 24 | * @param {string} message Error message in case the condition does not hold. 25 | */ 26 | export function validate(condition: any, message: string) { 27 | if (!condition) { 28 | throw new Error(message); 29 | } 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/buffer-layout/utils/native.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `buffer-layout-utils`, thanks for their work 3 | * https://github.com/solana-labs/buffer-layout-utils/tree/master/src 4 | */ 5 | import { Layout, u8 } from '../layout'; 6 | import { encodeDecode } from './base'; 7 | 8 | export const bool = (property?: string): Layout => { 9 | const layout = u8(property); 10 | const { encode, decode } = encodeDecode(layout); 11 | 12 | const boolLayout = layout as Layout as Layout; 13 | 14 | boolLayout.decode = (buffer: Buffer, offset: number) => { 15 | const src = decode(buffer, offset); 16 | return !!src; 17 | }; 18 | 19 | boolLayout.encode = (bool: boolean, buffer: Buffer, offset: number) => { 20 | const src = Number(bool); 21 | return encode(src, buffer, offset); 22 | }; 23 | 24 | return boolLayout; 25 | }; 26 | -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/kava/swap/v1beta1/tx.amino.ts: -------------------------------------------------------------------------------- 1 | import { MsgDeposit, MsgWithdraw, MsgSwapExactForTokens, MsgSwapForExactTokens } from "./tx"; 2 | export const SwapAminoConverter = { 3 | "/kava.swap.v1beta1.MsgDeposit": { 4 | aminoType: "swap/MsgDeposit", 5 | toAmino: MsgDeposit.toAmino, 6 | fromAmino: MsgDeposit.fromAmino 7 | }, 8 | "/kava.swap.v1beta1.MsgWithdraw": { 9 | aminoType: "swap/MsgWithdraw", 10 | toAmino: MsgWithdraw.toAmino, 11 | fromAmino: MsgWithdraw.fromAmino 12 | }, 13 | "/kava.swap.v1beta1.MsgSwapExactForTokens": { 14 | aminoType: "swap/MsgSwapExactForTokens", 15 | toAmino: MsgSwapExactForTokens.toAmino, 16 | fromAmino: MsgSwapExactForTokens.fromAmino 17 | }, 18 | "/kava.swap.v1beta1.MsgSwapForExactTokens": { 19 | aminoType: "swap/MsgSwapForExactTokens", 20 | toAmino: MsgSwapForExactTokens.toAmino, 21 | fromAmino: MsgSwapForExactTokens.fromAmino 22 | } 23 | }; -------------------------------------------------------------------------------- /bu-packages/coin-stellar/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.0.3](https://github.com/okx/js-wallet-sdk)(2025-05-25) 7 | 8 | - **coin-stellar:** Updated the sha.js dependency to v2.4.12 ([](https://github.com/okx/js-wallet-sdk)) 9 | 10 | # [1.0.2](https://github.com/okx/js-wallet-sdk)(2024-02-18) 11 | 12 | ### New Features 13 | 14 | - **coin-stellar:** support PI network , add validAddress for M address ([](https://github.com/okx/js-wallet-sdk)) 15 | 16 | 17 | # [1.0.1](https://github.com/okx/js-wallet-sdk)(2024-02-18) 18 | 19 | ### New Features 20 | 21 | - **coin-stellar:** support PI network ,add test case and function ([](https://github.com/okx/js-wallet-sdk)) 22 | 23 | 24 | # [1.0.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 25 | 26 | ### New Features 27 | 28 | - **coin-stellar:** support PI network ([](https://github.com/okx/js-wallet-sdk)) 29 | -------------------------------------------------------------------------------- /bu-packages/coin-sui/src/utils/intent.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // See: sui/crates/sui-types/src/intent.rs 5 | export enum AppId { 6 | Sui = 0, 7 | } 8 | 9 | export enum IntentVersion { 10 | V0 = 0, 11 | } 12 | 13 | export enum IntentScope { 14 | TransactionData = 0, 15 | TransactionEffects = 1, 16 | CheckpointSummary = 2, 17 | PersonalMessage = 3, 18 | } 19 | 20 | export type Intent = [IntentScope, IntentVersion, AppId]; 21 | 22 | function intentWithScope(scope: IntentScope): Intent { 23 | return [scope, IntentVersion.V0, AppId.Sui]; 24 | } 25 | 26 | export function messageWithIntent(scope: IntentScope, message: Uint8Array) { 27 | const intent = intentWithScope(scope); 28 | const intentMessage = new Uint8Array(intent.length + message.length); 29 | intentMessage.set(intent); 30 | intentMessage.set(message, intent.length); 31 | return intentMessage; 32 | } 33 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/boc/cell/exoticLibrary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { BitReader } from "../BitReader"; 10 | import { BitString } from "../BitString"; 11 | import { Cell } from "../Cell"; 12 | 13 | export function exoticLibrary(bits: BitString, refs: Cell[]) { 14 | const reader = new BitReader(bits); 15 | 16 | // type + hash 17 | const size = 8 + 256; 18 | 19 | if (bits.length !== size) { 20 | throw new Error(`Library cell must have exactly (8 + 256) bits, got "${bits.length}"`); 21 | } 22 | 23 | // Check type 24 | let type = reader.loadUint(8); 25 | if (type !== 2) { 26 | throw new Error(`Library cell must have type 2, got "${type}"`); 27 | } 28 | 29 | return {}; 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/PIWallet.ts: -------------------------------------------------------------------------------- 1 | import { 2 | GetDerivedPathParam 3 | } from "@okxweb3/coin-base"; 4 | import {StellarWallet} from "./StellarWallet"; 5 | 6 | 7 | 8 | export const PINetworks = { 9 | TESTNET: 'Pi Testnet', 10 | TESTNET2: 'Pi Testnet', 11 | MAINNET: 'Pi Network', 12 | }; 13 | 14 | 15 | export class PIWallet extends StellarWallet { 16 | async getDerivedPath(param: GetDerivedPathParam): Promise { 17 | return `m/44'/314159'/${param.index}'`; 18 | } 19 | 20 | // async getDerivedPrivateKey(param: DerivePriKeyParams): Promise { 21 | // try { 22 | // const key = await signUtil.ed25519.ed25519_getDerivedPrivateKey(param.mnemonic,param.hdPath, false, "hex") 23 | // return Promise.resolve(StrKey.encodeEd25519SecretSeed(base.fromHex(key))); 24 | // } catch (e) { 25 | // return Promise.reject(GenPrivateKeyError); 26 | // } 27 | // } 28 | } -------------------------------------------------------------------------------- /examples/src/pages/Btc.tsx: -------------------------------------------------------------------------------- 1 | import { Box, VStack} from "@chakra-ui/react"; 2 | import {useState} from "react"; 3 | import BtcSignTx from "../components/BtcSignTx"; 4 | import {BtcWallet} from "@okxweb3/coin-bitcoin"; 5 | import {BitcoinWallets} from "../components/types"; 6 | import BtcPrivateKey from "../components/BtcPrivateKey"; 7 | 8 | 9 | export default function Btc() { 10 | const [privateKey, setPrivateKey] = useState("L2Nk86vWbm8eETtJa8N6DCeejRRJkjcHuYufkMq4A8sCLroS1rKU") 11 | const [wallet, setWallet] = useState(new BtcWallet()) 12 | 13 | 14 | return ( 15 | 16 | 17 | 18 | 19 | 20 | 21 | ); 22 | 23 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/provider/types/configuration.type.ts: -------------------------------------------------------------------------------- 1 | import { NetworkName, StarknetChainId, SupportedRpcVersion } from '../../global/constants'; 2 | import { BlockIdentifier } from '../../types/lib'; 3 | import { ResourceBoundsOverhead } from './spec.type'; 4 | 5 | export interface ProviderOptions extends RpcProviderOptions {} 6 | 7 | export type FeeMarginPercentage = { 8 | bounds: ResourceBoundsOverhead; // V3 tx 9 | maxFee: number; // V legacy tx 10 | }; 11 | 12 | export type RpcProviderOptions = { 13 | nodeUrl?: string | NetworkName; 14 | retries?: number; 15 | transactionRetryIntervalFallback?: number; 16 | headers?: object; 17 | blockIdentifier?: BlockIdentifier; 18 | chainId?: StarknetChainId; 19 | specVersion?: SupportedRpcVersion; 20 | default?: boolean; 21 | waitMode?: boolean; 22 | baseFetch?: WindowOrWorkerGlobalScope['fetch']; 23 | feeMarginPercentage?: FeeMarginPercentage; 24 | batch?: false | number; 25 | }; 26 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/common/common.ts: -------------------------------------------------------------------------------- 1 | import {TokenContract} from "./contract"; 2 | 3 | 4 | export type TokenPrevTx = { 5 | prevTx: string, 6 | prevPrevTx: string, 7 | } 8 | 9 | // transfer 10 | export interface CatTransferParams 11 | { 12 | tokenMetadata: string 13 | feeInputs: UtxoInput[] 14 | feeRate: number 15 | tokens: string 16 | changeAddress: string 17 | toAddress: string 18 | tokenAmount: string 19 | tokenPrevTxs: TokenPrevTx[] 20 | verifyScript?: boolean 21 | guard? : string 22 | publicKey?: string 23 | signData?: SignData 24 | estimateFee?: boolean 25 | } 26 | 27 | export type UtxoInput = { 28 | txId: string 29 | vOut: number 30 | amount: number // min unit: satoshi 31 | address?: string 32 | } 33 | 34 | // sighashes to be signed or signatures after signing 35 | export type SignData = { 36 | merge: string[], 37 | commit: string[], 38 | reveal: string[], 39 | } -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/utils/bitsForNumber.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | export function bitsForNumber(src: bigint | number, mode: 'int' | 'uint'): number { 10 | let v = BigInt(src); 11 | 12 | // Handle negative values 13 | if (mode === 'int') { 14 | 15 | // Corner case for zero or -1 value 16 | if (v === 0n || v === -1n) { 17 | return 1; 18 | } 19 | 20 | let v2 = v > 0 ? v : -v; 21 | return (v2.toString(2).length + 1/* Sign bit */); 22 | } else if (mode === 'uint') { 23 | if (v < 0) { 24 | throw Error(`value is negative. Got ${src}`); 25 | } 26 | return (v.toString(2).length); 27 | } else { 28 | throw Error(`invalid mode. Got ${mode}`); 29 | } 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-base/src/base/hex.ts: -------------------------------------------------------------------------------- 1 | import {validateHexString} from "./helper"; 2 | 3 | export function toHex(data: Uint8Array | Buffer | number[], addPrefix: boolean = false): string { 4 | const buffer = Buffer.from(data) 5 | return addPrefix ? "0x" + buffer.toString("hex") : buffer.toString("hex") 6 | } 7 | 8 | export function fromHex(data: string): Buffer { 9 | if (data.startsWith("0x") || data.startsWith("0X")) { 10 | data = data.substring(2) 11 | } 12 | if (data.length % 2 != 0) { 13 | data = "0" + data 14 | } 15 | if (!validateHexString(data)) { 16 | throw new Error("invalid hex string") 17 | } 18 | return Buffer.from(data, "hex") 19 | } 20 | 21 | export function stripHexPrefix(hex: string): string { 22 | if (hex.startsWith("0x")) { 23 | return hex.substring(2) 24 | } 25 | return hex 26 | } 27 | 28 | export function isHexPrefixed(hex: string): boolean { 29 | return hex.startsWith("0x") 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/AuthorizationData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | import { Payload, payloadBeet } from './Payload'; 15 | export type AuthorizationData = { 16 | payload: Payload; 17 | }; 18 | 19 | /** 20 | * @category userTypes 21 | * @category generated 22 | */ 23 | export const authorizationDataBeet = new beet.FixableBeetArgsStruct( 24 | [['payload', payloadBeet]], 25 | 'AuthorizationData', 26 | ); 27 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/Payload.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | import { PayloadType, payloadTypeBeet } from './PayloadType'; 15 | export type Payload = { 16 | map: Map; 17 | }; 18 | 19 | /** 20 | * @category userTypes 21 | * @category generated 22 | */ 23 | export const payloadBeet = new beet.FixableBeetArgsStruct( 24 | [['map', beet.map(beet.utf8String, payloadTypeBeet)]], 25 | 'Payload', 26 | ); 27 | -------------------------------------------------------------------------------- /examples/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import {Box, ChakraProvider, theme } from "@chakra-ui/react" 3 | import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; 4 | import Header from "./components/Header"; 5 | import Home from "./pages/Home"; 6 | import Evm from "./pages/Evm"; 7 | import Btc from "./pages/Btc"; 8 | import Ton from "./pages/Ton"; 9 | 10 | export const App = () => ( 11 | 12 | 13 |
14 | 15 | 16 | }/> 17 | } /> 18 | } /> 19 | } /> 20 | 21 | 22 | 23 | 24 | ) 25 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/starknet-types-08/wallet-api/errors.ts: -------------------------------------------------------------------------------- 1 | export interface NOT_ERC20 { 2 | code: 111; 3 | message: 'An error occurred (NOT_ERC20)'; 4 | } 5 | 6 | export interface UNLISTED_NETWORK { 7 | code: 112; 8 | message: 'An error occurred (UNLISTED_NETWORK)'; 9 | } 10 | 11 | export interface USER_REFUSED_OP { 12 | code: 113; 13 | message: 'An error occurred (USER_REFUSED_OP)'; 14 | } 15 | 16 | export interface INVALID_REQUEST_PAYLOAD { 17 | code: 114; 18 | message: 'An error occurred (INVALID_REQUEST_PAYLOAD)'; 19 | } 20 | 21 | export interface ACCOUNT_ALREADY_DEPLOYED { 22 | code: 115; 23 | message: 'An error occurred (ACCOUNT_ALREADY_DEPLOYED)'; 24 | } 25 | 26 | export interface API_VERSION_NOT_SUPPORTED { 27 | code: 162; 28 | message: 'An error occurred (API_VERSION_NOT_SUPPORTED)'; 29 | data: 'string'; 30 | } 31 | 32 | export interface UNKNOWN_ERROR { 33 | code: 163; 34 | message: 'An error occurred (UNKNOWN_ERROR)'; 35 | } 36 | -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/lib/base/hex.ts: -------------------------------------------------------------------------------- 1 | import {validateHexString} from "./helper"; 2 | 3 | export function toHex(data: Uint8Array | Buffer | number[], addPrefix: boolean = false): string { 4 | const buffer = Buffer.from(data) 5 | return addPrefix ? "0x" + buffer.toString("hex") : buffer.toString("hex") 6 | } 7 | 8 | export function fromHex(data: string): Buffer { 9 | if (data.startsWith("0x") || data.startsWith("0X")) { 10 | data = data.substring(2) 11 | } 12 | if (data.length % 2 != 0) { 13 | data = "0" + data 14 | } 15 | if (!validateHexString(data)) { 16 | throw new Error("invalid hex string") 17 | } 18 | return Buffer.from(data, "hex") 19 | } 20 | 21 | export function stripHexPrefix(hex: string): string { 22 | if (hex.startsWith("0x")) { 23 | return hex.substring(2) 24 | } 25 | return hex 26 | } 27 | 28 | export function isHexPrefixed(hex: string): boolean { 29 | return hex.startsWith("0x") 30 | } -------------------------------------------------------------------------------- /bu-packages/crypto-lib/src/signutil/schnorr/_shortw_utils.ts: -------------------------------------------------------------------------------- 1 | /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ 2 | import { hmac } from '@noble/hashes/hmac'; 3 | import { concatBytes, randomBytes } from '@noble/hashes/utils'; 4 | import { weierstrass, CurveType } from './abstract/weierstrass'; 5 | import { CHash } from './abstract/utils'; 6 | 7 | // connects noble-curves to noble-hashes 8 | export function getHash(hash: CHash) { 9 | return { 10 | hash, 11 | hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => hmac(hash, key, concatBytes(...msgs)), 12 | randomBytes, 13 | }; 14 | } 15 | // Same API as @noble/hashes, with ability to create curve with custom hash 16 | type CurveDef = Readonly>; 17 | export function createCurve(curveDef: CurveDef, defHash: CHash) { 18 | const create = (hash: CHash) => weierstrass({ ...curveDef, ...getHash(hash) }); 19 | return Object.freeze({ ...create(defHash), create }); 20 | } -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/transactions/instances/identifier.ts: -------------------------------------------------------------------------------- 1 | // Copyright © Aptos Foundation 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | import { Deserializer } from "../../bcs/deserializer"; 5 | import { Serializable, Serializer } from "../../bcs/serializer"; 6 | 7 | /** 8 | * Representation of an Identifier that can serialized and deserialized. 9 | * We use Identifier to represent the module "name" in "ModuleId" and 10 | * the "function name" in "EntryFunction" 11 | */ 12 | export class Identifier extends Serializable { 13 | public identifier: string; 14 | 15 | constructor(identifier: string) { 16 | super(); 17 | this.identifier = identifier; 18 | } 19 | 20 | public serialize(serializer: Serializer): void { 21 | serializer.serializeStr(this.identifier); 22 | } 23 | 24 | static deserialize(deserializer: Deserializer): Identifier { 25 | const identifier = deserializer.deserializeStr(); 26 | return new Identifier(identifier); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/types/TickTock.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | import { Builder } from "../boc/Builder"; 10 | import { Slice } from "../boc/Slice"; 11 | 12 | // Source: https://github.com/ton-blockchain/ton/blob/24dc184a2ea67f9c47042b4104bbb4d82289fac1/crypto/block/block.tlb#L139 13 | // tick_tock$_ tick:Bool tock:Bool = TickTock; 14 | 15 | export type TickTock = { 16 | tick: boolean; 17 | tock: boolean; 18 | } 19 | 20 | export function loadTickTock(slice: Slice): TickTock { 21 | return { 22 | tick: slice.loadBit(), 23 | tock: slice.loadBit() 24 | }; 25 | } 26 | 27 | export function storeTickTock(src: TickTock) { 28 | return (builder: Builder) => { 29 | builder.storeBit(src.tick); 30 | builder.storeBit(src.tock); 31 | } 32 | } -------------------------------------------------------------------------------- /bu-packages/coin-cosmos/src/lib/kava/hard/v1beta1/tx.amino.ts: -------------------------------------------------------------------------------- 1 | import { MsgDeposit, MsgWithdraw, MsgBorrow, MsgRepay, MsgLiquidate } from "./tx"; 2 | export const HardAminoConverter = { 3 | "/kava.hard.v1beta1.MsgDeposit": { 4 | aminoType: "hard/MsgDeposit", 5 | toAmino: MsgDeposit.toAmino, 6 | fromAmino: MsgDeposit.fromAmino 7 | }, 8 | "/kava.hard.v1beta1.MsgWithdraw": { 9 | aminoType: "hard/MsgWithdraw", 10 | toAmino: MsgWithdraw.toAmino, 11 | fromAmino: MsgWithdraw.fromAmino 12 | }, 13 | "/kava.hard.v1beta1.MsgBorrow": { 14 | aminoType: "hard/MsgBorrow", 15 | toAmino: MsgBorrow.toAmino, 16 | fromAmino: MsgBorrow.fromAmino 17 | }, 18 | "/kava.hard.v1beta1.MsgRepay": { 19 | aminoType: "hard/MsgRepay", 20 | toAmino: MsgRepay.toAmino, 21 | fromAmino: MsgRepay.fromAmino 22 | }, 23 | "/kava.hard.v1beta1.MsgLiquidate": { 24 | aminoType: "hard/MsgLiquidate", 25 | toAmino: MsgLiquidate.toAmino, 26 | fromAmino: MsgLiquidate.fromAmino 27 | } 28 | }; -------------------------------------------------------------------------------- /bu-packages/coin-stacks/src/common/keys.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Blockstack Inc. 5 | * https://github.com/hirosystems/stacks.js/blob/main/LICENSE 6 | * */ 7 | 8 | import { hexToBytes } from './utils'; 9 | 10 | /** 11 | * @private 12 | * @ignore 13 | */ 14 | export function privateKeyToBytes(privateKey: string | Uint8Array): Uint8Array { 15 | const privateKeyBuffer = typeof privateKey === 'string' ? hexToBytes(privateKey) : privateKey; 16 | 17 | if (privateKeyBuffer.length != 32 && privateKeyBuffer.length != 33) { 18 | throw new Error( 19 | `Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${privateKeyBuffer.length}` 20 | ); 21 | } 22 | 23 | if (privateKeyBuffer.length == 33 && privateKeyBuffer[32] !== 1) { 24 | throw new Error( 25 | 'Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01' 26 | ); 27 | } 28 | 29 | return privateKeyBuffer; 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/helpers/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Exclusive one of types (no intersection allowed) 3 | * OneOf<[A, B]> = exclusive A OR B, where (all props of A) OR (all props of B) 4 | * A | B = inclusive A OR B, where all prop of A and any prop of B and vice versa 5 | */ 6 | export type OneOf< 7 | TypesArray extends any[], 8 | Res = never, 9 | AllProperties = MergeTypes, 10 | > = TypesArray extends [infer Head, ...infer Rem] 11 | ? OneOf, AllProperties> 12 | : Res; 13 | 14 | export type SimpleOneOf = OnlyFirst | OnlyFirst; 15 | 16 | type MergeTypes = TypesArray extends [infer Head, ...infer Rem] 17 | ? MergeTypes 18 | : Res; 19 | 20 | type OnlyFirst = F & { [Key in keyof Omit]?: undefined }; // ?: never collapse to : undefined 21 | 22 | /** 23 | * set all lvl1 props to never 24 | */ 25 | 26 | export type AllNever = Record; 27 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib/signer' 2 | export * from './lib/types' 3 | export * from './lib/utils/hash' 4 | export * from './lib/account' 5 | 6 | 7 | /** 8 | * Utils 9 | */ 10 | export * as constants from './lib/global/constants'; 11 | export * as encode from './lib/utils/encode'; 12 | export * as hash from './lib/utils/hash'; 13 | export * as json from './lib/utils/json'; 14 | export * as num from './lib/utils/num'; 15 | export * as transaction from './lib/utils/transaction'; 16 | export * as stark from './lib/utils/stark'; 17 | export * as ec from './lib/utils/ec'; 18 | export * as merkle from './lib/utils/merkle'; 19 | export * as uint256 from './lib/utils/uint256'; 20 | export * as shortString from './lib/utils/shortString'; 21 | export * as typedData from './lib/utils/typedData'; 22 | export * from './lib/utils/address'; 23 | export * from './lib/utils/calldata'; 24 | 25 | export * from './message' 26 | export * from './key' 27 | export * from './transaction' 28 | export * from './StarknetWallet' -------------------------------------------------------------------------------- /examples/src/components/AddressOutput.tsx: -------------------------------------------------------------------------------- 1 | import {CheckIcon, CopyIcon, StarIcon} from "@chakra-ui/icons"; 2 | import {Alert, AlertIcon, Heading, IconButton, useClipboard} from "@chakra-ui/react"; 3 | 4 | interface AddressProps { 5 | address: string 6 | } 7 | const AddressOutput: React.FC = (props) =>{ 8 | const { hasCopied: hasCopiedAddress, onCopy: onCopyAddress } = useClipboard(props.address); 9 | return ( 10 | props.address ? 11 | 12 | 13 | {"Address: " + props.address } 14 | : } 18 | aria-label={hasCopiedAddress ? 'Copied' : 'Copy'} 19 | /> 20 | 21 | :
22 | ) 23 | } 24 | export default AddressOutput -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/patches/scrypt-ts+1.4.3.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/scrypt-ts/dist/client/apis/contract/sync-hashed-props.js b/node_modules/scrypt-ts/dist/client/apis/contract/sync-hashed-props.js 2 | index 38da3ed..58c0259 100644 3 | --- a/node_modules/scrypt-ts/dist/client/apis/contract/sync-hashed-props.js 4 | +++ b/node_modules/scrypt-ts/dist/client/apis/contract/sync-hashed-props.js 5 | @@ -6,7 +6,8 @@ const hashed_map_1 = require("../../../smart-contract/builtins/hashed-map"); 6 | const types_1 = require("../../../smart-contract/builtins/types"); 7 | ; 8 | // monkey patch BigInt.toJSON as recommended by https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json 9 | -BigInt.prototype.toJSON = function () { return this.toString(); }; 10 | +// remove this monkey patch because it is not compatible with SES 11 | +// BigInt.prototype.toJSON = function () { return this.toString(); }; 12 | class SyncHashedPropsAction { 13 | constructor() { 14 | this.method = 'POST'; 15 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/AuthorityType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | /** 15 | * @category enums 16 | * @category generated 17 | */ 18 | export enum AuthorityType { 19 | None, 20 | Metadata, 21 | Holder, 22 | MetadataDelegate, 23 | TokenDelegate, 24 | } 25 | 26 | /** 27 | * @category userTypes 28 | * @category generated 29 | */ 30 | export const authorityTypeBeet = beet.fixedScalarEnum(AuthorityType) as beet.FixedSizeBeet< 31 | AuthorityType, 32 | AuthorityType 33 | >; 34 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/types/BigNumber.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `types`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/types 4 | */ 5 | import type { Buffer } from 'buffer'; 6 | import { BN } from '@okxweb3/coin-base'; 7 | import type { Opaque, Option } from '../utils'; 8 | 9 | export type BigNumber = Opaque; 10 | export type BigNumberValues = 11 | | number 12 | | string 13 | | number[] 14 | | Uint8Array 15 | | Buffer 16 | | BN; 17 | 18 | export const toBigNumber = ( 19 | value: BigNumberValues, 20 | endian?: BN.Endianness 21 | ): BigNumber => { 22 | return new BN(value, endian) as BigNumber; 23 | }; 24 | 25 | export const toOptionBigNumber = ( 26 | value: Option 27 | ): Option => { 28 | return value === null ? null : toBigNumber(value); 29 | }; 30 | 31 | export const isBigNumber = (value: any): value is BigNumber => { 32 | return value?.__opaque__ === 'BigNumber'; 33 | }; 34 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/src/v2/types/codegen.yaml: -------------------------------------------------------------------------------- 1 | overwrite: true 2 | documents: src/internal/queries/**/*.graphql 3 | schema: https://indexer.mainnet.aptoslabs.com/v1/graphql 4 | generates: 5 | src/types/generated/types.ts: 6 | plugins: 7 | - typescript 8 | config: 9 | skipTypename: true 10 | namingConvention: 11 | transformUnderscore: true 12 | src/types/generated/operations.ts: 13 | preset: import-types-preset 14 | presetConfig: 15 | typesPath: ./types 16 | plugins: 17 | - typescript-operations 18 | config: 19 | skipTypename: true 20 | namingConvention: 21 | transformUnderscore: true 22 | src/types/generated/queries.ts: 23 | preset: import-types-preset 24 | presetConfig: 25 | typesPath: ./operations 26 | plugins: 27 | - typescript-graphql-request 28 | config: 29 | documentMode: string 30 | documentVariableSuffix: "" 31 | skipTypename: true 32 | namingConvention: 33 | transformUnderscore: true 34 | -------------------------------------------------------------------------------- /bu-packages/coin-stellar/src/lib/operations/account_merge.js: -------------------------------------------------------------------------------- 1 | import xdr from '../xdr'; 2 | import { decodeAddressToMuxedAccount } from '../util/decode_encode_muxed_account'; 3 | 4 | /** 5 | * Transfers native balance to destination account. 6 | * 7 | * @function 8 | * @alias Operation.accountMerge 9 | * 10 | * @param {object} opts - options object 11 | * @param {string} opts.destination - destination to merge the source account into 12 | * @param {string} [opts.source] - operation source account (defaults to 13 | * transaction source) 14 | * 15 | * @returns {xdr.Operation} an Account Merge operation (xdr.AccountMergeOp) 16 | */ 17 | export function accountMerge(opts) { 18 | const opAttributes = {}; 19 | try { 20 | opAttributes.body = xdr.OperationBody.accountMerge( 21 | decodeAddressToMuxedAccount(opts.destination) 22 | ); 23 | } catch (e) { 24 | throw new Error('destination is invalid'); 25 | } 26 | this.setSourceAccount(opAttributes, opts); 27 | 28 | return new xdr.Operation(opAttributes); 29 | } 30 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/buffer-layout/utils/web3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `buffer-layout-utils`, thanks for their work 3 | * https://github.com/solana-labs/buffer-layout-utils/tree/master/src 4 | */ 5 | import { blob, Layout } from '../layout'; 6 | import { PublicKey } from '../../web3'; 7 | import { encodeDecode } from './base'; 8 | 9 | export const publicKey = (property?: string): Layout => { 10 | const layout = blob(32, property); 11 | const { encode, decode } = encodeDecode(layout); 12 | 13 | const publicKeyLayout = layout as Layout as Layout; 14 | 15 | publicKeyLayout.decode = (buffer: Buffer, offset: number) => { 16 | const src = decode(buffer, offset); 17 | return new PublicKey(src); 18 | }; 19 | 20 | publicKeyLayout.encode = (publicKey: PublicKey, buffer: Buffer, offset: number) => { 21 | const src = publicKey.toBuffer(); 22 | return encode(src, buffer, offset); 23 | }; 24 | 25 | return publicKeyLayout; 26 | }; 27 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/TokenStandard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | /** 15 | * @category enums 16 | * @category generated 17 | */ 18 | export enum TokenStandard { 19 | NonFungible, 20 | FungibleAsset, 21 | Fungible, 22 | NonFungibleEdition, 23 | ProgrammableNonFungible, 24 | } 25 | 26 | /** 27 | * @category userTypes 28 | * @category generated 29 | */ 30 | export const tokenStandardBeet = beet.fixedScalarEnum(TokenStandard) as beet.FixedSizeBeet< 31 | TokenStandard, 32 | TokenStandard 33 | >; 34 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/wallet/CatWallet.ts: -------------------------------------------------------------------------------- 1 | import { SignTxParams} from "@okxweb3/coin-base"; 2 | import { BtcWallet } from "./BtcWallet"; 3 | import { transfer } from "../cat20" 4 | 5 | export class CatWallet extends BtcWallet { 6 | 7 | async signTransaction(param: SignTxParams): Promise { 8 | try { 9 | const tx = await transfer(param) 10 | return Promise.resolve(tx); 11 | } catch (e) { 12 | return Promise.reject(e); 13 | } 14 | } 15 | 16 | async estimateFee(param: SignTxParams): Promise { 17 | try { 18 | param.data.estimateFee = true 19 | const fees = await transfer(param) 20 | return Promise.resolve(fees); 21 | } catch (e) { 22 | return Promise.reject(e); 23 | } 24 | } 25 | } 26 | // fractal testnet uses same network info as bitcoin & fractal mainnet 27 | // export class CatTestWallet extends CatWallet { 28 | // network() { 29 | // return bitcoin.networks.testnet; 30 | // } 31 | // } 32 | -------------------------------------------------------------------------------- /bu-packages/coin-cardano/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-cardano:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.6](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-cardano:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | 19 | # [1.0.3](https://github.com/okx/js-wallet-sdk) (2024-07-01) 20 | 21 | ### Fix 22 | 23 | - **coin-cardano:** update library for private key path derivation 24 | 25 | # [1.0.2](https://github.com/okx/js-wallet-sdk) (2024-06-13) 26 | 27 | ### Fix 28 | 29 | - **coin-cardano:** support derive private key for multi accounts 30 | 31 | 32 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2023-11-15) 33 | 34 | ### Feature 35 | 36 | - **coin-cardano:** support signMessage and signRawTx ([25](https://github.com/okx/js-wallet-sdk/pull/25)) 37 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/types/Program.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `types`, thanks for their work 3 | * https://github.com/metaplex-foundation/js/tree/main/packages/js/src/types 4 | */ 5 | import {PublicKey, SystemProgram} from '../../web3'; 6 | import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "../mpl-token-metadata"; 7 | import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from "../../spl"; 8 | 9 | export type Program = { 10 | name: string; 11 | address: PublicKey; 12 | }; 13 | 14 | export const tokenMetadataProgram: Program = { 15 | name: 'TokenMetadataProgram', 16 | address: TOKEN_METADATA_PROGRAM_ID, 17 | }; 18 | 19 | export const tokenProgram: Program = { 20 | name: 'TokenProgram', 21 | address: TOKEN_PROGRAM_ID, 22 | }; 23 | 24 | export const associatedTokenProgram: Program = { 25 | name: 'AssociatedTokenProgram', 26 | address: ASSOCIATED_TOKEN_PROGRAM_ID, 27 | }; 28 | 29 | export const systemProgram: Program = { 30 | name: 'SystemProgram', 31 | address: SystemProgram.programId, 32 | }; 33 | -------------------------------------------------------------------------------- /bu-packages/coin-bitcoin/src/cat20/transaction/merge.ts: -------------------------------------------------------------------------------- 1 | import {UTXO} from "scrypt-ts"; 2 | import {EcKeyService} from "../utils"; 3 | import {btc} from "../common"; 4 | 5 | export function mergeFee( 6 | ecKey: EcKeyService, 7 | feeUtxos: UTXO[], 8 | feeRate: number, 9 | ){ 10 | 11 | const address = ecKey.getAddress(); 12 | const mergeTx = new btc.Transaction() 13 | .from(feeUtxos) 14 | .feePerByte(feeRate) 15 | .change(address); 16 | 17 | if (mergeTx.getChangeOutput() === null) { 18 | throw new Error('Insufficient satoshis balance!'); 19 | } 20 | const output = mergeTx.outputs[0] 21 | output.satoshis -= 1; 22 | 23 | if (ecKey.hasPrivateKey()) { 24 | ecKey.signTx(mergeTx); 25 | } 26 | 27 | const mergedFeeUtxo: UTXO = { 28 | address, 29 | txId: mergeTx.id, 30 | outputIndex: 0, 31 | script: output.script, 32 | satoshis: output.satoshis, 33 | } 34 | 35 | return { 36 | mergeTx, 37 | feeUtxo: mergedFeeUtxo, 38 | } 39 | } -------------------------------------------------------------------------------- /bu-packages/coin-near/src/nearlib.ts: -------------------------------------------------------------------------------- 1 | import { Schema, serialize } from 'borsh'; 2 | 3 | export interface SignMessageParamsNEP { 4 | message: string 5 | recipient: string 6 | nonce: Buffer 7 | callbackUrl?: string 8 | state?: string 9 | } 10 | 11 | 12 | export interface SignMessageParams { 13 | chainId: string 14 | messageParams: SignMessageParamsNEP & { 15 | accountId?: string 16 | } 17 | } 18 | 19 | export class MessagePayload { 20 | tag: number 21 | message: string 22 | nonce: Buffer 23 | recipient: string 24 | callbackUrl?: string 25 | 26 | constructor(data: SignMessageParamsNEP) { 27 | // The tag's value is a hardcoded value as per 28 | // defined in the NEP [NEP413](https://github.com/near/NEPs/blob/master/neps/nep-0413.md) 29 | this.tag = 2147484061 30 | this.message = data.message 31 | this.nonce = data.nonce 32 | this.recipient = data.recipient 33 | if (data.callbackUrl) { 34 | this.callbackUrl = data.callbackUrl 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /bu-packages/coin-tron/src/lib/protobuf/Discover.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package protocol; 4 | 5 | 6 | option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file 7 | option java_outer_classname = "Discover"; //Specify the class name of the generated Java file 8 | option go_package = "github.com/tronprotocol/grpc-gateway/core"; 9 | 10 | message Endpoint { 11 | bytes address = 1; 12 | int32 port = 2; 13 | bytes nodeId = 3; 14 | } 15 | 16 | message PingMessage { 17 | Endpoint from = 1; 18 | Endpoint to = 2; 19 | int32 version = 3; 20 | int64 timestamp = 4; 21 | } 22 | 23 | message PongMessage { 24 | Endpoint from = 1; 25 | int32 echo = 2; 26 | int64 timestamp = 3; 27 | } 28 | 29 | message FindNeighbours { 30 | Endpoint from = 1; 31 | bytes targetId = 2; 32 | int64 timestamp = 3; 33 | } 34 | 35 | message Neighbours { 36 | Endpoint from = 1; 37 | repeated Endpoint neighbours = 2; 38 | int64 timestamp = 3; 39 | } 40 | 41 | message BackupMessage { 42 | bool flag = 1; 43 | int32 priority = 2; 44 | } -------------------------------------------------------------------------------- /bu-packages/coin-ethereum/src/lib/sdk/ethereumjs-util/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `ethereumjs/util`, thanks for their work 3 | * https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util 4 | * Distributed under the Mozilla Public License Version 2.0 software license, see the accompanying 5 | * file LICENSE or https://opensource.org/license/mpl-2-0/. 6 | */ 7 | 8 | /** 9 | * Constants 10 | */ 11 | export * from './constants' 12 | 13 | /** 14 | * Account class and helper functions 15 | */ 16 | export * from './account' 17 | 18 | /** 19 | * Address type 20 | */ 21 | export * from './address' 22 | 23 | /** 24 | * Hash functions 25 | */ 26 | export * from './hash' 27 | 28 | /** 29 | * ECDSA signature 30 | */ 31 | export * from './signature' 32 | 33 | /** 34 | * Utilities for manipulating Buffers, byte arrays, etc. 35 | */ 36 | export * from './bytes' 37 | 38 | /** 39 | * Helpful TypeScript types 40 | */ 41 | export * from './types' 42 | 43 | 44 | export * as rlp from './rlp' 45 | 46 | export * from './util' 47 | 48 | 49 | -------------------------------------------------------------------------------- /bu-packages/coin-solana/src/lib/metaplex/mpl-token-metadata/types/TokenDelegateRole.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The following methods are based on `mpl-token-metadata`, thanks for their work 3 | * https://github.com/metaplex-foundation/mpl-token-metadata/tree/main/programs/token-metadata/js/src/generated/types 4 | */ 5 | 6 | /** 7 | * This code was GENERATED using the solita package. 8 | * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. 9 | * 10 | * See: https://github.com/metaplex-foundation/solita 11 | */ 12 | 13 | import * as beet from '@metaplex-foundation/beet'; 14 | /** 15 | * @category enums 16 | * @category generated 17 | */ 18 | export enum TokenDelegateRole { 19 | Sale, 20 | Transfer, 21 | Utility, 22 | Staking, 23 | Standard, 24 | LockedTransfer, 25 | Migration, 26 | } 27 | 28 | /** 29 | * @category userTypes 30 | * @category generated 31 | */ 32 | export const tokenDelegateRoleBeet = beet.fixedScalarEnum(TokenDelegateRole) as beet.FixedSizeBeet< 33 | TokenDelegateRole, 34 | TokenDelegateRole 35 | >; 36 | -------------------------------------------------------------------------------- /bu-packages/coin-kaspa/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 7 | 8 | ### New Features 9 | 10 | - **coin-kaspa:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 11 | 12 | # [1.0.5](https://github.com/okx/js-wallet-sdk) (2024-08-20) 13 | 14 | ### Fix 15 | 16 | - **coin-kaspa:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 17 | 18 | # [1.0.3](https://github.com/okx/js-wallet-sdk) (2023-12-05) 19 | 20 | ### Feature 21 | 22 | - **coin-kaspa:** add transfer, sign message ([40](https://github.com/okx/js-wallet-sdk/pull/40)) 23 | 24 | # [1.0.2](https://github.com/okx/js-wallet-sdk) (2023-11-17) 25 | 26 | ### Bug Fixes 27 | 28 | - **coin-kaspa:** fix address validate ([26](https://github.com/okx/js-wallet-sdk/pull/26)) 29 | 30 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2023-11-13) 31 | 32 | ### Bug Fixes 33 | 34 | - **coin-kaspa:** add index.ts ([23](https://github.com/okx/js-wallet-sdk/pull/23)) 35 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/utils/crc32c.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Whales Corp. 3 | * All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | const POLY = 0x82f63b78; 10 | 11 | export function crc32c(source: Buffer) { 12 | let crc = 0 ^ 0xffffffff; 13 | for (let n = 0; n < source.length; n++) { 14 | crc ^= source[n]; 15 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 16 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 17 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 18 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 19 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 20 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 21 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 22 | crc = crc & 1 ? (crc >>> 1) ^ POLY : crc >>> 1; 23 | } 24 | crc = crc ^ 0xffffffff; 25 | 26 | // Convert endianness 27 | let res = Buffer.alloc(4); 28 | res.writeInt32LE(crc); 29 | return res; 30 | } -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/lib/contract/index.ts: -------------------------------------------------------------------------------- 1 | import { ValuesType } from '../../helpers/valuesType'; 2 | import { LegacyCompiledContract, LegacyContractClass } from './legacy'; 3 | import { CompiledSierra, SierraContractClass } from './sierra'; 4 | 5 | // Final types 6 | /** 7 | * format produced after compressing compiled contract 8 | * 9 | * CompressedCompiledContract 10 | */ 11 | export type ContractClass = LegacyContractClass | SierraContractClass; 12 | 13 | /** 14 | * format produced after compile .cairo to .json 15 | */ 16 | export type CompiledContract = LegacyCompiledContract | CompiledSierra; 17 | 18 | /** 19 | * Compressed or decompressed Cairo0 or Cairo1 Contract 20 | */ 21 | export type CairoContract = ContractClass | CompiledContract; 22 | 23 | // Basic elements 24 | export const EntryPointType = { 25 | EXTERNAL: 'EXTERNAL', 26 | L1_HANDLER: 'L1_HANDLER', 27 | CONSTRUCTOR: 'CONSTRUCTOR', 28 | } as const; 29 | 30 | export type EntryPointType = ValuesType; 31 | 32 | export * from './abi'; 33 | export * from './legacy'; 34 | export * from './sierra'; 35 | -------------------------------------------------------------------------------- /bu-packages/coin-aptos/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Change Log 3 | 4 | All notable changes to this project will be documented in this file. 5 | 6 | 7 | # [1.2.0](https://github.com/okx/js-wallet-sdk)(2024-01-15) 8 | 9 | ### New Features 10 | 11 | - **coin-aptos:** support signCommonMsg ([](https://github.com/okx/js-wallet-sdk)) 12 | 13 | # [1.1.0](https://github.com/okx/js-wallet-sdk)(2024-01-09) 14 | 15 | ### New Features 16 | 17 | - **coin-aptos:** support build simulate transaction ([](https://github.com/okx/js-wallet-sdk)) 18 | 19 | # [1.0.7](https://github.com/okx/js-wallet-sdk) (2024-08-20) 20 | 21 | ### New Features 22 | 23 | - **coin-aptos:** support Fungible Asset, compatible with different dapp protocols ([](https://github.com/okx/js-wallet-sdk)) 24 | 25 | ### Fix 26 | 27 | - **coin-aptos:** upgrade private key verification ([](https://github.com/okx/js-wallet-sdk)) 28 | 29 | 30 | # [1.0.1](https://github.com/okx/js-wallet-sdk) (2023-11-17) 31 | 32 | ### Bug Fixes 33 | 34 | - **coin-aptos:** support for module 0x1::object::Object and 0x1::option::Option ([30](https://github.com/okx/js-wallet-sdk/pull/30)) 35 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/utils/calldata/parser/parser-0-1.1.0.ts: -------------------------------------------------------------------------------- 1 | import { Abi, FunctionAbi } from '../../../types'; 2 | import { isLen } from '../cairo'; 3 | import { AbiParserInterface } from './interface'; 4 | 5 | export class AbiParser1 implements AbiParserInterface { 6 | abi: Abi; 7 | 8 | constructor(abi: Abi) { 9 | this.abi = abi; 10 | } 11 | 12 | /** 13 | * abi method inputs length without '_len' inputs 14 | * cairo 0 reducer 15 | * @param abiMethod FunctionAbi 16 | * @returns number 17 | */ 18 | public methodInputsLength(abiMethod: FunctionAbi) { 19 | return abiMethod.inputs.reduce((acc, input) => (!isLen(input.name) ? acc + 1 : acc), 0); 20 | } 21 | 22 | /** 23 | * get method definition from abi 24 | * @param name string 25 | * @returns FunctionAbi | undefined 26 | */ 27 | public getMethod(name: string): FunctionAbi | undefined { 28 | return this.abi.find((it) => it.name === name); 29 | } 30 | 31 | /** 32 | * Get Abi in legacy format 33 | * @returns Abi 34 | */ 35 | public getLegacyFormat() { 36 | return this.abi; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bu-packages/coin-ton/src/lib/ton-core/dict/generateMerkleUpdate.ts: -------------------------------------------------------------------------------- 1 | import { beginCell } from '../boc/Builder'; 2 | import { Cell } from '../boc/Cell'; 3 | import { DictionaryKeyTypes, Dictionary, DictionaryKey } from './Dictionary'; 4 | import { generateMerkleProof } from './generateMerkleProof'; 5 | 6 | function convertToMerkleUpdate(c1: Cell, c2: Cell): Cell { 7 | return beginCell() 8 | .storeUint(4, 8) 9 | .storeBuffer(c1.hash(0)) 10 | .storeBuffer(c2.hash(0)) 11 | .storeUint(c1.depth(0), 16) 12 | .storeUint(c2.depth(0), 16) 13 | .storeRef(c1) 14 | .storeRef(c2) 15 | .endCell({ exotic: true }); 16 | } 17 | 18 | export function generateMerkleUpdate( 19 | dict: Dictionary, 20 | key: K, 21 | keyObject: DictionaryKey, 22 | newValue: V 23 | ): Cell { 24 | const oldProof = generateMerkleProof(dict, [key], keyObject).refs[0]; 25 | dict.set(key, newValue); 26 | const newProof = generateMerkleProof(dict, [key], keyObject).refs[0]; 27 | return convertToMerkleUpdate(oldProof, newProof); 28 | } 29 | -------------------------------------------------------------------------------- /bu-packages/coin-starknet/src/lib/types/lib/contract/legacy.ts: -------------------------------------------------------------------------------- 1 | import { Abi } from './abi'; 2 | 3 | /** LEGACY CONTRACT */ 4 | /** 5 | * format produced after compressing 'program' property 6 | */ 7 | export type LegacyContractClass = { 8 | program: CompressedProgram; 9 | entry_points_by_type: EntryPointsByType; 10 | abi: Abi; 11 | }; 12 | 13 | /** 14 | * format produced after compiling .cairo to .json 15 | */ 16 | export type LegacyCompiledContract = Omit & { 17 | program: Program; 18 | }; 19 | 20 | /** SUBTYPES */ 21 | export type Builtins = string[]; 22 | export type CompressedProgram = string; 23 | 24 | export type EntryPointsByType = { 25 | CONSTRUCTOR: ContractEntryPointFields[]; 26 | EXTERNAL: ContractEntryPointFields[]; 27 | L1_HANDLER: ContractEntryPointFields[]; 28 | }; 29 | 30 | export type ContractEntryPointFields = { 31 | selector: string; 32 | offset: string | number; 33 | builtins?: Builtins; 34 | }; 35 | 36 | export interface Program extends Record { 37 | builtins: string[]; 38 | data: string[]; 39 | // TODO: Add missing properties 40 | } 41 | --------------------------------------------------------------------------------