From f1e9351f9e5d0cc7f17365fff1bc9d0960152fac Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Mon, 3 Feb 2025 21:54:06 +0100 Subject: [PATCH 01/10] Add groupless address --- packages/web3/src/address/address.test.ts | 28 +- packages/web3/src/address/address.ts | 54 +- packages/web3/src/api/api-alephium.ts | 619 ++++++++++++++---- packages/web3/src/api/node-provider.ts | 3 + .../src/codec/lockup-script-codec.test.ts | 13 +- .../web3/src/codec/lockup-script-codec.ts | 21 +- .../web3/src/codec/unlock-script-codec.ts | 22 +- packages/web3/src/contract/contract.ts | 4 +- packages/web3/src/contract/ralph.ts | 18 +- packages/web3/src/signer/signer.ts | 2 +- packages/web3/src/signer/tx-builder.ts | 86 ++- packages/web3/src/signer/types.ts | 38 +- packages/web3/src/utils/sign.test.ts | 11 + packages/web3/src/utils/sign.ts | 4 +- 14 files changed, 758 insertions(+), 165 deletions(-) diff --git a/packages/web3/src/address/address.test.ts b/packages/web3/src/address/address.test.ts index 64965f36b..2cb2bb2f1 100644 --- a/packages/web3/src/address/address.test.ts +++ b/packages/web3/src/address/address.test.ts @@ -29,12 +29,14 @@ import { isAssetAddress, isContractAddress, isValidAddress, - addressFromScript, - groupOfLockupScript + groupOfLockupScript, + isGrouplessAddress } from './address' import { binToHex, bs58 } from '../utils' import { randomBytes } from 'crypto' -import { LockupScript, lockupScriptCodec } from '../codec/lockup-script-codec' +import { LockupScript } from '../codec/lockup-script-codec' +import { intAs4BytesCodec } from '../codec/int-as-4bytes-codec' +import djb2 from '../utils/djb2' describe('address', function () { it('should validate address', () => { @@ -62,6 +64,8 @@ describe('address', function () { validateAddress('2jVWAcAPphJ8ueZNG1BPwbfPFjjbvorprceuqzgmJQ1ZRyELRpWgARvdB3T9trqpiJs7f4GkudPt6rQLnGbQYqq2NCi') ).toThrow('Invalid multisig address, n: 2, m: 3') expect(() => validateAddress('thebear')).toThrow('Invalid multisig address') + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBeUndefined() + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8Bdjfv')).toThrow('Invalid checksum for P2PK address:') }) it('should return if an address is valid', () => { @@ -92,6 +96,10 @@ describe('address', function () { expect(isContractAddress('vobthYg1e9tPKhmF96rpkv3akCj7vhvgPpsP4qwZqDw3')).toEqual(true) expect(() => isAssetAddress('15EM5rGtt7dPRZScE4Z9oL2EDfj84JnoSgq3NNgdcGF')).toThrow('Invalid address:') expect(() => isContractAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9k')).toThrow('Invalid address:') + expect(isGrouplessAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(true) + expect(isGrouplessAddress('vobthYg1e9tPKhmF96rpkv3akCj7vhvgPpsP4qwZqDw3')).toEqual(false) + expect(isGrouplessAddress('qeKk7r92Vn2Xjn4GcMEcJ2EwVfVs27kWUpptrWcWsUWC')).toEqual(false) + expect(() => isGrouplessAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9k')).toThrow('Invalid address:') }) it('should calculate the group of addresses', () => { @@ -125,6 +133,7 @@ describe('address', function () { const bytes0 = new Uint8Array(randomBytes(32)) const bytes1 = new Uint8Array(randomBytes(32)) const bytes2 = new Uint8Array(randomBytes(32)) + const bytes4 = new Uint8Array(randomBytes(33)) const p2pkh: LockupScript = { kind: 'P2PKH', value: new Uint8Array(bytes0) } const p2pkhAddress = bs58.encode(new Uint8Array([0x00, ...bytes0])) @@ -141,6 +150,13 @@ describe('address', function () { const p2c: LockupScript = { kind: 'P2C', value: bytes0 } const p2cAddress = bs58.encode(new Uint8Array([0x03, ...bytes0])) expect(groupOfAddress(p2cAddress)).toBe(groupOfLockupScript(p2c)) + + const publicKeyLike = new Uint8Array([0x00, ...bytes4]) + const checkSum = intAs4BytesCodec.encode(djb2(publicKeyLike)) + const scriptHint = djb2(bytes4) | 1 + const p2pk: LockupScript = { kind: 'P2PK', value: { type: 0, publicKey: bytes4, scriptHint, checkSum} } + const p2pkAddress = bs58.encode(new Uint8Array([0x04, 0x00, ...bytes4, ...checkSum])) + expect(groupOfAddress(p2pkAddress)).toBe(groupOfLockupScript(p2pk)) }) it('should extract token id from addresses', () => { @@ -176,6 +192,12 @@ describe('address', function () { expect(addressFromPublicKey('030f9f042a9410969f1886f85fa20f6e43176ae23fc5e64db15b3767c84c5db2dc')).toBe( '1ACCkgFfmTif46T3qK12znuWjb5Bk9jXpqaeWt2DXx8oc' ) + expect(addressFromPublicKey('029592852f5d289785904b89a073ff80ee6155c894b1d13ecb16bcf3ac02473e1a', 'groupless')).toBe( + '3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK' + ) + expect(addressFromPublicKey('aecfc38a48f5fe7e050fca59de9f8d77fa7a7d9e63af608a95f8839de397f48a', 'bip340-schnorr')).toBe( + 'qvegNNcKFBtkMcZTLj42pki2YDYTvHaGyBxBaWrPaHwj' + ) }) it('should convert between contract id and address', () => { diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index 1ff8f700f..1ed083a17 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -24,7 +24,7 @@ import bs58, { base58ToBytes } from '../utils/bs58' import { binToHex, concatBytes, hexToBinUnsafe, isHexString, xorByte } from '../utils' import { KeyType } from '../signer' import { P2MPKH, lockupScriptCodec } from '../codec/lockup-script-codec' -import { i32Codec } from '../codec' +import { i32Codec, intAs4BytesCodec } from '../codec' import { LockupScript } from '../codec/lockup-script-codec' import djb2 from '../utils/djb2' import { TraceableError } from '../error' @@ -36,7 +36,8 @@ export enum AddressType { P2PKH = 0x00, P2MPKH = 0x01, P2SH = 0x02, - P2C = 0x03 + P2C = 0x03, + P2PK = 0x04 } export function validateAddress(address: string) { @@ -53,6 +54,7 @@ export function isValidAddress(address: string): boolean { } function decodeAndValidateAddress(address: string): Uint8Array { + // TODO: Need to consider groupless address with @group const decoded = base58ToBytes(address) if (decoded.length === 0) throw new Error('Address is empty') const addressType = decoded[0] @@ -75,6 +77,17 @@ function decodeAndValidateAddress(address: string): Uint8Array { } else if (addressType === AddressType.P2PKH || addressType === AddressType.P2SH || addressType === AddressType.P2C) { // [type, ...hash] if (decoded.length === 33) return decoded + } else if (addressType === AddressType.P2PK) { + // [type, keyType, ...publicKey, ...checkSum] + if (decoded.length === 39) { + const publicKeyLikeBytes = decoded.slice(1, 35) // Include the keyType byte + const checksum = binToHex(decoded.slice(35, 39)) + const expectedChecksum = binToHex(intAs4BytesCodec.encode(djb2(publicKeyLikeBytes))) + if (checksum !== expectedChecksum) { + throw new Error(`Invalid checksum for P2PK address: ${address}`) + } + return decoded + } } throw new Error(`Invalid address: ${address}`) @@ -82,7 +95,12 @@ function decodeAndValidateAddress(address: string): Uint8Array { export function isAssetAddress(address: string) { const addressType = decodeAndValidateAddress(address)[0] - return addressType === AddressType.P2PKH || addressType === AddressType.P2MPKH || addressType === AddressType.P2SH + return addressType === AddressType.P2PKH || addressType === AddressType.P2MPKH || addressType === AddressType.P2SH || addressType === AddressType.P2PK +} + +export function isGrouplessAddress(address: string) { + const addressType = decodeAndValidateAddress(address)[0] + return addressType === AddressType.P2PK } export function isContractAddress(address: string) { @@ -101,6 +119,8 @@ export function groupOfAddress(address: string): number { return groupOfP2mpkhAddress(addressBody) } else if (addressType == AddressType.P2SH) { return groupOfP2shAddress(addressBody) + } else if (addressType == AddressType.P2PK) { + return groupOfP2pkAddress(addressBody) } else { // Contract Address const id = contractIdFromAddress(address) @@ -110,17 +130,21 @@ export function groupOfAddress(address: string): number { // Pay to public key hash address function groupOfP2pkhAddress(address: Uint8Array): number { - return groupFromBytesForAssetAddress(address) + return groupFromBytes(address) } // Pay to multiple public key hash address function groupOfP2mpkhAddress(address: Uint8Array): number { - return groupFromBytesForAssetAddress(address.slice(1, 33)) + return groupFromBytes(address.slice(1, 33)) +} + +function groupOfP2pkAddress(address: Uint8Array): number { + return groupFromBytes(address.slice(1, 34)) } // Pay to script hash address function groupOfP2shAddress(address: Uint8Array): number { - return groupFromBytesForAssetAddress(address) + return groupFromBytes(address) } export function contractIdFromAddress(address: string): Uint8Array { @@ -151,7 +175,7 @@ export function groupOfPrivateKey(privateKey: string, keyType?: KeyType): number export function publicKeyFromPrivateKey(privateKey: string, _keyType?: KeyType): string { const keyType = _keyType ?? 'default' - if (keyType === 'default') { + if (keyType === 'default' || keyType === 'groupless') { const key = ec.keyFromPrivate(privateKey) return key.getPublic(true, 'hex') } else { @@ -166,6 +190,11 @@ export function addressFromPublicKey(publicKey: string, _keyType?: KeyType): str const hash = blake.blake2b(hexToBinUnsafe(publicKey), undefined, 32) const bytes = new Uint8Array([AddressType.P2PKH, ...hash]) return bs58.encode(bytes) + } else if (keyType === 'groupless') { + const publicKeyBytes = new Uint8Array([0x00, ...hexToBinUnsafe(publicKey)]) + const hashBytes = intAs4BytesCodec.encode(djb2(publicKeyBytes)) + const bytes = new Uint8Array([0x04, ...publicKeyBytes, ...hashBytes]) + return bs58.encode(bytes) } else { const lockupScript = hexToBinUnsafe(`0101000000000458144020${publicKey}8685`) return addressFromScript(lockupScript) @@ -215,11 +244,14 @@ export function subContractId(parentContractId: string, pathInHex: string, group export function groupOfLockupScript(lockupScript: LockupScript): number { if (lockupScript.kind === 'P2PKH') { - return groupFromBytesForAssetAddress(lockupScript.value) + return groupFromBytes(lockupScript.value) } else if (lockupScript.kind === 'P2MPKH') { - return groupFromBytesForAssetAddress(lockupScript.value.publicKeyHashes[0]) + return groupFromBytes(lockupScript.value.publicKeyHashes[0]) } else if (lockupScript.kind === 'P2SH') { - return groupFromBytesForAssetAddress(lockupScript.value) + return groupFromBytes(lockupScript.value) + } else if (lockupScript.kind === 'P2PK') { + // FIXME: support @group for groupless address + return groupFromBytes(lockupScript.value.publicKey) } else { // P2C const contractId = lockupScript.value @@ -227,7 +259,7 @@ export function groupOfLockupScript(lockupScript: LockupScript): number { } } -function groupFromBytesForAssetAddress(bytes: Uint8Array): number { +export function groupFromBytes(bytes: Uint8Array): number { const hint = djb2(bytes) | 1 const hash = xorByte(hint) return hash % TOTAL_NUMBER_OF_GROUPS diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index 3c311199c..30855cb10 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -9,6 +9,15 @@ * --------------------------------------------------------------- */ +/** AddressAssetState */ +export interface AddressAssetState { + /** @format address */ + address: string + /** @format uint256 */ + attoAlphAmount: string + tokens?: Token[] +} + /** AddressBalance */ export interface AddressBalance { /** @format address */ @@ -308,7 +317,66 @@ export interface BuildExecuteScriptTxResult { gasPrice: string /** @format 32-byte-hash */ txId: string - simulatedOutputs: Output[] + simulationResult: SimulationResult +} + +/** BuildGrouplessDeployContractTx */ +export interface BuildGrouplessDeployContractTx { + /** @format address */ + fromAddress: string + /** @format hex-string */ + bytecode: string + /** @format uint256 */ + initialAttoAlphAmount?: string + initialTokenAmounts?: Token[] + /** @format uint256 */ + issueTokenAmount?: string + /** @format address */ + issueTokenTo?: string + /** @format uint256 */ + gasPrice?: string + /** @format block-hash */ + targetBlockHash?: string +} + +/** BuildGrouplessDeployContractTxResult */ +export interface BuildGrouplessDeployContractTxResult { + transferTxs: BuildTransferTxResult[] + deployContractTx: BuildDeployContractTxResult +} + +/** BuildGrouplessExecuteScriptTx */ +export interface BuildGrouplessExecuteScriptTx { + /** @format address */ + fromAddress: string + /** @format hex-string */ + bytecode: string + /** @format uint256 */ + attoAlphAmount?: string + tokens?: Token[] + /** @format uint256 */ + gasPrice?: string + /** @format block-hash */ + targetBlockHash?: string + /** @format double */ + gasEstimationMultiplier?: number +} + +/** BuildGrouplessExecuteScriptTxResult */ +export interface BuildGrouplessExecuteScriptTxResult { + transferTxs: BuildTransferTxResult[] + executeScriptTx: BuildExecuteScriptTxResult +} + +/** BuildGrouplessTransferTx */ +export interface BuildGrouplessTransferTx { + /** @format address */ + fromAddress: string + destinations: Destination[] + /** @format uint256 */ + gasPrice?: string + /** @format block-hash */ + targetBlockHash?: string } /** BuildInfo */ @@ -715,7 +783,7 @@ export interface Destination { /** @format address */ address: string /** @format uint256 */ - attoAlphAmount: string + attoAlphAmount?: string tokens?: Token[] /** @format int64 */ lockTime?: number @@ -781,6 +849,11 @@ export interface FunctionSig { returnTypes: string[] } +/** GatewayTimeout */ +export interface GatewayTimeout { + detail: string +} + /** GhostUncleBlockEntry */ export interface GhostUncleBlockEntry { /** @format block-hash */ @@ -1098,6 +1171,12 @@ export interface SignResult { signature: string } +/** SimulationResult */ +export interface SimulationResult { + contractInputs: AddressAssetState[] + generatedOutputs: AddressAssetState[] +} + /** Source */ export interface Source { /** @format hex-string */ @@ -1194,7 +1273,7 @@ export interface TestContract { /** @format address */ address?: string /** @format address */ - callerAddress?: string + callerContractAddress?: string /** @format contract */ bytecode: string initialImmFields?: Val[] @@ -1649,7 +1728,7 @@ export class HttpClient { /** * @title Alephium API - * @version 3.10.0 + * @version 3.12.0 * @baseUrl ../ */ export class Api extends HttpClient { @@ -1663,7 +1742,10 @@ export class Api extends HttpClient - this.request({ + this.request< + WalletStatus[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets`, method: 'GET', format: 'json', @@ -1681,7 +1763,7 @@ export class Api extends HttpClient this.request< WalletRestoreResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/wallets`, method: 'PUT', @@ -1702,7 +1784,7 @@ export class Api extends HttpClient this.request< WalletCreationResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/wallets`, method: 'POST', @@ -1721,7 +1803,10 @@ export class Api extends HttpClient - this.request({ + this.request< + WalletStatus, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}`, method: 'GET', format: 'json', @@ -1743,7 +1828,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}`, method: 'DELETE', query: query, @@ -1759,7 +1847,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/lock`, method: 'POST', ...params @@ -1774,7 +1865,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/unlock`, method: 'POST', body: data, @@ -1791,7 +1885,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Balances, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/balances`, method: 'GET', format: 'json', @@ -1809,7 +1906,7 @@ export class Api extends HttpClient this.request< RevealMnemonicResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/wallets/${walletName}/reveal-mnemonic`, method: 'POST', @@ -1828,7 +1925,10 @@ export class Api extends HttpClient - this.request({ + this.request< + TransferResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/transfer`, method: 'POST', body: data, @@ -1846,7 +1946,10 @@ export class Api extends HttpClient - this.request({ + this.request< + TransferResults, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/sweep-active-address`, method: 'POST', body: data, @@ -1864,7 +1967,10 @@ export class Api extends HttpClient - this.request({ + this.request< + TransferResults, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/sweep-all-addresses`, method: 'POST', body: data, @@ -1882,7 +1988,10 @@ export class Api extends HttpClient - this.request({ + this.request< + SignResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/sign`, method: 'POST', body: data, @@ -1900,7 +2009,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Addresses, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/addresses`, method: 'GET', format: 'json', @@ -1916,7 +2028,10 @@ export class Api extends HttpClient - this.request({ + this.request< + AddressInfo, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/addresses/${address}`, method: 'GET', format: 'json', @@ -1934,7 +2049,7 @@ export class Api extends HttpClient this.request< MinerAddressesInfo[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/wallets/${walletName}/miner-addresses`, method: 'GET', @@ -1958,7 +2073,10 @@ export class Api extends HttpClient - this.request({ + this.request< + AddressInfo, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/derive-next-address`, method: 'POST', query: query, @@ -1975,7 +2093,10 @@ export class Api extends HttpClient - this.request({ + this.request< + AddressInfo[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/derive-next-miner-addresses`, method: 'POST', format: 'json', @@ -1995,7 +2116,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/wallets/${walletName}/change-active-address`, method: 'POST', body: data, @@ -2013,7 +2137,10 @@ export class Api extends HttpClient - this.request({ + this.request< + NodeInfo, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/node`, method: 'GET', format: 'json', @@ -2029,7 +2156,10 @@ export class Api extends HttpClient - this.request({ + this.request< + NodeVersion, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/version`, method: 'GET', format: 'json', @@ -2045,7 +2175,10 @@ export class Api extends HttpClient - this.request({ + this.request< + ChainParams, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/chain-params`, method: 'GET', format: 'json', @@ -2061,7 +2194,10 @@ export class Api extends HttpClient - this.request({ + this.request< + SelfClique, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/self-clique`, method: 'GET', format: 'json', @@ -2079,7 +2215,7 @@ export class Api extends HttpClient this.request< InterCliquePeerInfo[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/infos/inter-clique-peer-info`, method: 'GET', @@ -2096,7 +2232,10 @@ export class Api extends HttpClient - this.request({ + this.request< + BrokerInfo[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/discovered-neighbors`, method: 'GET', format: 'json', @@ -2112,7 +2251,10 @@ export class Api extends HttpClient - this.request({ + this.request< + PeerMisbehavior[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/misbehaviors`, method: 'GET', format: 'json', @@ -2128,7 +2270,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/misbehaviors`, method: 'POST', body: data, @@ -2145,7 +2290,10 @@ export class Api extends HttpClient - this.request({ + this.request< + string[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/unreachable`, method: 'GET', format: 'json', @@ -2161,7 +2309,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/discovery`, method: 'POST', body: data, @@ -2192,7 +2343,10 @@ export class Api extends HttpClient - this.request({ + this.request< + HashRateResponse, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/history-hashrate`, method: 'GET', query: query, @@ -2218,7 +2372,10 @@ export class Api extends HttpClient - this.request({ + this.request< + HashRateResponse, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/current-hashrate`, method: 'GET', query: query, @@ -2235,7 +2392,10 @@ export class Api extends HttpClient - this.request({ + this.request< + CurrentDifficulty, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/infos/current-difficulty`, method: 'GET', format: 'json', @@ -2268,7 +2428,7 @@ export class Api extends HttpClient this.request< BlocksPerTimeStampRange, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/blockflow/blocks`, method: 'GET', @@ -2302,7 +2462,7 @@ export class Api extends HttpClient this.request< BlocksAndEventsPerTimeStampRange, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/blockflow/blocks-with-events`, method: 'GET', @@ -2336,7 +2496,7 @@ export class Api extends HttpClient this.request< RichBlocksAndEventsPerTimeStampRange, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/blockflow/rich-blocks`, method: 'GET', @@ -2354,7 +2514,10 @@ export class Api extends HttpClient - this.request({ + this.request< + BlockEntry, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/blocks/${blockHash}`, method: 'GET', format: 'json', @@ -2370,7 +2533,10 @@ export class Api extends HttpClient - this.request({ + this.request< + BlockEntry, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/main-chain-block-by-ghost-uncle/${ghostUncleHash}`, method: 'GET', format: 'json', @@ -2386,7 +2552,10 @@ export class Api extends HttpClient - this.request({ + this.request< + BlockAndEvents, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/blocks-with-events/${blockHash}`, method: 'GET', format: 'json', @@ -2402,14 +2571,15 @@ export class Api extends HttpClient - this.request( - { - path: `/blockflow/rich-blocks/${blockHash}`, - method: 'GET', - format: 'json', - ...params - } - ).then(convertHttpResponse), + this.request< + RichBlockAndEvents, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/blockflow/rich-blocks/${blockHash}`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), /** * No description @@ -2426,7 +2596,10 @@ export class Api extends HttpClient - this.request({ + this.request< + boolean, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/is-block-in-main-chain`, method: 'GET', query: query, @@ -2453,7 +2626,10 @@ export class Api extends HttpClient - this.request({ + this.request< + HashesAtHeight, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/hashes`, method: 'GET', query: query, @@ -2478,7 +2654,10 @@ export class Api extends HttpClient - this.request({ + this.request< + ChainInfo, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/chain-info`, method: 'GET', query: query, @@ -2495,7 +2674,10 @@ export class Api extends HttpClient - this.request({ + this.request< + BlockHeaderEntry, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/headers/${blockHash}`, method: 'GET', format: 'json', @@ -2511,7 +2693,10 @@ export class Api extends HttpClient - this.request({ + this.request< + RawBlock, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/blockflow/raw-blocks/${blockHash}`, method: 'GET', format: 'json', @@ -2534,7 +2719,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Balance, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/addresses/${address}/balance`, method: 'GET', query: query, @@ -2551,7 +2739,10 @@ export class Api extends HttpClient - this.request({ + this.request< + UTXOs, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/addresses/${address}/utxos`, method: 'GET', format: 'json', @@ -2567,7 +2758,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Group, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/addresses/${address}/group`, method: 'GET', format: 'json', @@ -2586,7 +2780,7 @@ export class Api extends HttpClient this.request< BuildTransferTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/build`, method: 'POST', @@ -2607,7 +2801,7 @@ export class Api extends HttpClient this.request< BuildTransferTxResult[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/build-transfer-from-one-to-many-groups`, method: 'POST', @@ -2628,7 +2822,7 @@ export class Api extends HttpClient this.request< BuildTransferTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/build-multi-addresses`, method: 'POST', @@ -2649,7 +2843,7 @@ export class Api extends HttpClient this.request< BuildSweepAddressTransactionsResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/sweep-address/build`, method: 'POST', @@ -2668,7 +2862,10 @@ export class Api extends HttpClient - this.request({ + this.request< + SubmitTxResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/submit`, method: 'POST', body: data, @@ -2688,7 +2885,7 @@ export class Api extends HttpClient this.request< DecodeUnsignedTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/decode-unsigned-tx`, method: 'POST', @@ -2716,7 +2913,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Transaction, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/details/${txId}`, method: 'GET', query: query, @@ -2742,7 +2942,10 @@ export class Api extends HttpClient - this.request({ + this.request< + RichTransaction, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/rich-details/${txId}`, method: 'GET', query: query, @@ -2768,7 +2971,10 @@ export class Api extends HttpClient - this.request({ + this.request< + RawTransaction, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/raw/${txId}`, method: 'GET', query: query, @@ -2795,7 +3001,10 @@ export class Api extends HttpClient - this.request({ + this.request< + TxStatus, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/status`, method: 'GET', query: query, @@ -2820,7 +3029,10 @@ export class Api extends HttpClient - this.request({ + this.request< + string, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/transactions/tx-id-from-outputref`, method: 'GET', query: query, @@ -2839,7 +3051,7 @@ export class Api extends HttpClient this.request< BuildChainedTxResult[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/transactions/build-chained`, method: 'POST', @@ -2861,7 +3073,7 @@ export class Api extends HttpClient this.request< MempoolTransactions[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/mempool/transactions`, method: 'GET', @@ -2878,7 +3090,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/mempool/transactions`, method: 'DELETE', ...params @@ -2899,7 +3114,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/mempool/transactions/rebroadcast`, method: 'PUT', query: query, @@ -2915,7 +3133,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/mempool/transactions/validate`, method: 'PUT', ...params @@ -2933,7 +3154,7 @@ export class Api extends HttpClient this.request< CompileScriptResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/compile-script`, method: 'POST', @@ -2954,7 +3175,7 @@ export class Api extends HttpClient this.request< BuildExecuteScriptTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/unsigned-tx/execute-script`, method: 'POST', @@ -2975,7 +3196,7 @@ export class Api extends HttpClient this.request< CompileContractResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/compile-contract`, method: 'POST', @@ -2996,7 +3217,7 @@ export class Api extends HttpClient this.request< CompileProjectResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/compile-project`, method: 'POST', @@ -3017,7 +3238,7 @@ export class Api extends HttpClient this.request< BuildDeployContractTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/unsigned-tx/deploy-contract`, method: 'POST', @@ -3036,7 +3257,10 @@ export class Api extends HttpClient - this.request({ + this.request< + ContractState, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/contracts/${address}/state`, method: 'GET', format: 'json', @@ -3052,7 +3276,10 @@ export class Api extends HttpClient - this.request({ + this.request< + string, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/contracts/${codeHash}/code`, method: 'GET', format: 'json', @@ -3068,16 +3295,17 @@ export class Api extends HttpClient - this.request( - { - path: `/contracts/test-contract`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params - } - ).then(convertHttpResponse), + this.request< + TestContractResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/contracts/test-contract`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), /** * No description @@ -3088,16 +3316,17 @@ export class Api extends HttpClient - this.request( - { - path: `/contracts/call-contract`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params - } - ).then(convertHttpResponse), + this.request< + CallContractResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/contracts/call-contract`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), /** * No description @@ -3110,7 +3339,7 @@ export class Api extends HttpClient this.request< MultipleCallContractResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/contracts/multicall-contract`, method: 'POST', @@ -3129,7 +3358,10 @@ export class Api extends HttpClient - this.request({ + this.request< + string, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/contracts/${address}/parent`, method: 'GET', format: 'json', @@ -3154,7 +3386,10 @@ export class Api extends HttpClient - this.request({ + this.request< + SubContracts, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/contracts/${address}/sub-contracts`, method: 'GET', query: query, @@ -3171,7 +3406,10 @@ export class Api extends HttpClient - this.request({ + this.request< + number, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/contracts/${address}/sub-contracts/current-count`, method: 'GET', format: 'json', @@ -3187,16 +3425,17 @@ export class Api extends HttpClient - this.request( - { - path: `/contracts/call-tx-script`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params - } - ).then(convertHttpResponse) + this.request< + CallTxScriptResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/contracts/call-tx-script`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse) } multisig = { /** @@ -3210,7 +3449,7 @@ export class Api extends HttpClient this.request< BuildMultisigAddressResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/multisig/address`, method: 'POST', @@ -3231,7 +3470,7 @@ export class Api extends HttpClient this.request< BuildTransferTxResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/multisig/build`, method: 'POST', @@ -3252,7 +3491,7 @@ export class Api extends HttpClient this.request< BuildSweepAddressTransactionsResult, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/multisig/sweep`, method: 'POST', @@ -3271,7 +3510,10 @@ export class Api extends HttpClient - this.request({ + this.request< + SubmitTxResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/multisig/submit`, method: 'POST', body: data, @@ -3295,7 +3537,10 @@ export class Api extends HttpClient - this.request({ + this.request< + boolean, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/miners/cpu-mining`, method: 'POST', query: query, @@ -3320,7 +3565,10 @@ export class Api extends HttpClient - this.request({ + this.request< + boolean, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/miners/cpu-mining/mine-one-block`, method: 'POST', query: query, @@ -3337,7 +3585,10 @@ export class Api extends HttpClient - this.request({ + this.request< + MinerAddresses, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/miners/addresses`, method: 'GET', format: 'json', @@ -3353,7 +3604,10 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/miners/addresses`, method: 'PUT', body: data, @@ -3382,7 +3636,10 @@ export class Api extends HttpClient - this.request({ + this.request< + ContractEvents, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/events/contract/${contractAddress}`, method: 'GET', query: query, @@ -3399,7 +3656,10 @@ export class Api extends HttpClient - this.request({ + this.request< + number, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/events/contract/${contractAddress}/current-count`, method: 'GET', format: 'json', @@ -3424,7 +3684,7 @@ export class Api extends HttpClient this.request< ContractEventsByTxId, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/events/tx-id/${txId}`, method: 'GET', @@ -3451,7 +3711,7 @@ export class Api extends HttpClient this.request< ContractEventsByBlockHash, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout >({ path: `/events/block-hash/${blockHash}`, method: 'GET', @@ -3470,7 +3730,10 @@ export class Api extends HttpClient - this.request({ + this.request< + boolean, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/utils/verify-signature`, method: 'POST', body: data, @@ -3488,7 +3751,10 @@ export class Api extends HttpClient - this.request({ + this.request< + Result, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/utils/target-to-hashrate`, method: 'POST', body: data, @@ -3506,10 +3772,103 @@ export class Api extends HttpClient - this.request({ + this.request< + void, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ path: `/utils/check-hash-indexing`, method: 'PUT', ...params }).then(convertHttpResponse) } + groupless = { + /** + * No description + * + * @tags Groupless + * @name PostGrouplessTransfer + * @summary Build unsigned transfer transactions from a groupless address + * @request POST:/groupless/transfer + */ + postGrouplessTransfer: (data: BuildGrouplessTransferTx, params: RequestParams = {}) => + this.request< + BuildTransferTxResult[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/groupless/transfer`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * No description + * + * @tags Groupless + * @name PostGrouplessExecuteScript + * @summary Build an unsigned execute script transaction from a groupless address + * @request POST:/groupless/execute-script + */ + postGrouplessExecuteScript: (data: BuildGrouplessExecuteScriptTx, params: RequestParams = {}) => + this.request< + BuildGrouplessExecuteScriptTxResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/groupless/execute-script`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * No description + * + * @tags Groupless + * @name PostGrouplessDeployContract + * @summary Build an unsigned deploy contract transaction from a groupless address + * @request POST:/groupless/deploy-contract + */ + postGrouplessDeployContract: (data: BuildGrouplessDeployContractTx, params: RequestParams = {}) => + this.request< + BuildGrouplessDeployContractTxResult, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/groupless/deploy-contract`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * No description + * + * @tags Groupless + * @name GetGrouplessAddressBalance + * @summary Get the balance of a groupless address + * @request GET:/groupless/{address}/balance + */ + getGrouplessAddressBalance: ( + address: string, + query?: { + mempool?: boolean + }, + params: RequestParams = {} + ) => + this.request< + Balance, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout + >({ + path: `/groupless/${address}/balance`, + method: 'GET', + query: query, + format: 'json', + ...params + }).then(convertHttpResponse) + } } diff --git a/packages/web3/src/api/node-provider.ts b/packages/web3/src/api/node-provider.ts index 45e89496a..d4237b281 100644 --- a/packages/web3/src/api/node-provider.ts +++ b/packages/web3/src/api/node-provider.ts @@ -55,6 +55,7 @@ interface NodeProviderApis { utils: NodeApi['utils'] miners: NodeApi['miners'] events: NodeApi['events'] + groupless: NodeApi['groupless'] } export class NodeProvider implements NodeProviderApis { @@ -69,6 +70,7 @@ export class NodeProvider implements NodeProviderApis { readonly utils: NodeApi['utils'] readonly miners: NodeApi['miners'] readonly events: NodeApi['events'] + readonly groupless: NodeApi['groupless'] constructor(baseUrl: string, apiKey?: string, customFetch?: typeof fetch) constructor(provider: NodeProvider) @@ -95,6 +97,7 @@ export class NodeProvider implements NodeProviderApis { this.utils = { ...nodeApi.utils } this.miners = { ...nodeApi.miners } this.events = { ...nodeApi.events } + this.groupless = { ...nodeApi.groupless } requestWithLog(this) } diff --git a/packages/web3/src/codec/lockup-script-codec.test.ts b/packages/web3/src/codec/lockup-script-codec.test.ts index 0564458f7..4178a79df 100644 --- a/packages/web3/src/codec/lockup-script-codec.test.ts +++ b/packages/web3/src/codec/lockup-script-codec.test.ts @@ -16,13 +16,18 @@ You should have received a copy of the GNU Lesser General Public License along with the library. If not, see . */ import { randomBytes } from 'crypto' -import { LockupScript, lockupScriptCodec } from './lockup-script-codec' +import { LockupScript, lockupScriptCodec, P2PC } from './lockup-script-codec' +import djb2 from '../utils/djb2' +import { intAs4BytesCodec } from './int-as-4bytes-codec' +import { binToHex, bs58, hexToBinUnsafe } from '../utils' +import { tokenIdFromAddress } from '../address' describe('LockupScript', function () { it('should encode & decode lockup script', function () { const bytes0 = new Uint8Array(randomBytes(32)) const bytes1 = new Uint8Array(randomBytes(32)) const bytes2 = new Uint8Array(randomBytes(32)) + const bytes3 = new Uint8Array(randomBytes(33)) test(new Uint8Array([0x00, ...bytes0]), { kind: 'P2PKH', value: new Uint8Array(bytes0) }) const encodedMultisig = new Uint8Array([0x01, 0x03, ...bytes0, ...bytes1, ...bytes2, 0x02]) @@ -30,6 +35,12 @@ describe('LockupScript', function () { test(encodedMultisig, { kind: 'P2MPKH', value: p2mpkh }) test(new Uint8Array([0x02, ...bytes0]), { kind: 'P2SH', value: new Uint8Array(bytes0) }) test(new Uint8Array([0x03, ...bytes0]), { kind: 'P2C', value: new Uint8Array(bytes0) }) + + const checkSum = intAs4BytesCodec.encode(djb2(bytes3)) + const scriptHint = djb2(bytes3) | 1 + const scriptHintBytes = intAs4BytesCodec.encode(scriptHint) + const p2pk = { type: 0x00, publicKey: bytes3, checkSum, scriptHint } + test(new Uint8Array([0x04, 0x00, ...bytes3, ...checkSum, ...scriptHintBytes]), { kind: 'P2PK', value: p2pk }) }) function test(encoded: Uint8Array, expected: LockupScript) { diff --git a/packages/web3/src/codec/lockup-script-codec.ts b/packages/web3/src/codec/lockup-script-codec.ts index a21ef0204..c1b2c6a47 100644 --- a/packages/web3/src/codec/lockup-script-codec.ts +++ b/packages/web3/src/codec/lockup-script-codec.ts @@ -16,8 +16,9 @@ You should have received a copy of the GNU Lesser General Public License along with the library. If not, see . */ import { i32Codec } from './compact-int-codec' -import { byte32Codec, EnumCodec, ObjectCodec } from './codec' +import { byte32Codec, byteCodec, EnumCodec, FixedSizeCodec, ObjectCodec } from './codec' import { ArrayCodec } from './array-codec' +import { intAs4BytesCodec } from './int-as-4bytes-codec' export type PublicKeyHash = Uint8Array export type P2PKH = Uint8Array @@ -31,20 +32,36 @@ export interface P2MPKH { m: number } +export interface P2PC { + type: number + publicKey: Uint8Array + checkSum: Uint8Array + scriptHint: number +} + const p2mpkhCodec = new ObjectCodec({ publicKeyHashes: new ArrayCodec(byte32Codec), m: i32Codec }) +const p2pkCodec = new ObjectCodec({ + type: byteCodec, + publicKey: new FixedSizeCodec(33), + checkSum: new FixedSizeCodec(4), + scriptHint: intAs4BytesCodec +}) + export type LockupScript = | { kind: 'P2PKH'; value: P2PKH } | { kind: 'P2MPKH'; value: P2MPKH } | { kind: 'P2SH'; value: P2SH } | { kind: 'P2C'; value: P2C } + | { kind: 'P2PK'; value: P2PC } export const lockupScriptCodec = new EnumCodec('lockup script', { P2PKH: byte32Codec, P2MPKH: p2mpkhCodec, P2SH: byte32Codec, - P2C: byte32Codec + P2C: byte32Codec, + P2PK: p2pkCodec }) diff --git a/packages/web3/src/codec/unlock-script-codec.ts b/packages/web3/src/codec/unlock-script-codec.ts index f0d532345..3b213a609 100644 --- a/packages/web3/src/codec/unlock-script-codec.ts +++ b/packages/web3/src/codec/unlock-script-codec.ts @@ -17,13 +17,13 @@ along with the library. If not, see . */ import { ArrayCodec } from './array-codec' import { i32Codec } from './compact-int-codec' -import { Codec, EnumCodec, FixedSizeCodec, ObjectCodec } from './codec' +import { byteCodec, Codec, EnumCodec, FixedSizeCodec, ObjectCodec } from './codec' import { Script, scriptCodec } from './script-codec' import { Val, valsCodec } from './val' -export type P2PKH = Uint8Array +export type PublicKey = Uint8Array export interface KeyWithIndex { - publicKey: P2PKH + publicKey: PublicKey index: number } export type P2MPKH = KeyWithIndex[] @@ -33,15 +33,19 @@ export interface P2SH { } export type SameAsPrevious = 'SameAsPrevious' +export type KeyType = number + export type UnlockScript = - | { kind: 'P2PKH'; value: P2PKH } + | { kind: 'P2PKH'; value: PublicKey } | { kind: 'P2MPKH'; value: P2MPKH } | { kind: 'P2SH'; value: P2SH } | { kind: 'SameAsPrevious'; value: SameAsPrevious } + | { kind: 'PoLW'; value: PublicKey } + | { kind: 'P2PK'; value: KeyType } -const p2pkhCodec = new FixedSizeCodec(33) +const publicKeyCodec = new FixedSizeCodec(33) const keyWithIndexCodec = new ObjectCodec({ - publicKey: p2pkhCodec, + publicKey: publicKeyCodec, index: i32Codec }) const p2mpkhCodec: Codec = new ArrayCodec(keyWithIndexCodec) @@ -59,10 +63,12 @@ const sameAsPreviousCodec = new (class extends Codec { })() export const unlockScriptCodec = new EnumCodec('unlock script', { - P2PKH: p2pkhCodec, + P2PKH: publicKeyCodec, P2MPKH: p2mpkhCodec, P2SH: p2shCodec, - SameAsPrevious: sameAsPreviousCodec + SameAsPrevious: sameAsPreviousCodec, + PoLW: publicKeyCodec, + P2PK: byteCodec }) export const encodedSameAsPrevious = unlockScriptCodec.encode({ kind: 'SameAsPrevious', value: 'SameAsPrevious' }) diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index c10e0cbbf..73406237c 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -482,7 +482,7 @@ export class Contract extends Artifact { blockTimeStamp: params.blockTimeStamp, txId: params.txId, address: params.address, - callerAddress: params.callerAddress, + callerContractAddress: params.callerContractAddress, bytecode: this.isInlineFunc(methodIndex) ? this.getByteCodeForTesting() : this.bytecodeDebug, initialImmFields: immFields, initialMutFields: mutFields, @@ -967,7 +967,7 @@ export interface TestContractParams< > { group?: number // default 0 address?: string - callerAddress?: string + callerContractAddress?: string blockHash?: string blockTimeStamp?: number txId?: string diff --git a/packages/web3/src/contract/ralph.ts b/packages/web3/src/contract/ralph.ts index 86677b316..2f51e9f16 100644 --- a/packages/web3/src/contract/ralph.ts +++ b/packages/web3/src/contract/ralph.ts @@ -30,10 +30,12 @@ import { instrCodec, u256Codec, toU256, - toI256 + toI256, + intAs4BytesCodec } from '../codec' import { boolCodec } from '../codec/codec' import { TraceableError } from '../error' +import djb2 from '../utils/djb2' export function encodeByteVec(hex: string): Uint8Array { if (!isHexString(hex)) { @@ -45,7 +47,19 @@ export function encodeByteVec(hex: string): Uint8Array { } export function encodeAddress(address: string): Uint8Array { - return bs58.decode(address) + // Check if address has group suffix (e.g. "@0") + if (address.length > 2 && address[address.length - 2] === '@') { + throw new Error("TODO: support groupless address with @group") + } else { + const decoded = bs58.decode(address) + if (decoded[0] === 0x04 && decoded.length === 39) { + // If it is groupless address without @group, we need to add script hint + const publicKeyBytes = decoded.slice(2, 35) + const scriptHintBytes = intAs4BytesCodec.encode(djb2(publicKeyBytes) | 1) + return new Uint8Array([...decoded, ...scriptHintBytes]) + } + return decoded + } } export enum VmValType { diff --git a/packages/web3/src/signer/signer.ts b/packages/web3/src/signer/signer.ts index d8f6c716b..616e44da7 100644 --- a/packages/web3/src/signer/signer.ts +++ b/packages/web3/src/signer/signer.ts @@ -298,5 +298,5 @@ export function toApiDestinations(data: Destination[]): node.Destination[] { } export function fromApiDestination(data: node.Destination): Destination { - return { ...data, attoAlphAmount: fromApiNumber256(data.attoAlphAmount), tokens: fromApiTokens(data.tokens) } + return { ...data, attoAlphAmount: fromApiNumber256(data.attoAlphAmount ?? '0'), tokens: fromApiTokens(data.tokens) } } diff --git a/packages/web3/src/signer/tx-builder.ts b/packages/web3/src/signer/tx-builder.ts index ba1c87259..ea6fce58e 100644 --- a/packages/web3/src/signer/tx-builder.ts +++ b/packages/web3/src/signer/tx-builder.ts @@ -34,7 +34,11 @@ import { SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, - SignUnsignedTxResult + SignUnsignedTxResult, + SignGrouplessTransferTxParams, + SignGrouplessDeployContractTxParams, + SignTransferChainedTxResult, + SignGrouplessExecuteScriptTxParams } from './types' import { unsignedTxCodec } from '../codec' import { groupIndexOfTransaction } from '../transaction' @@ -154,6 +158,51 @@ export abstract class TransactionBuilder { return results } + async buildGrouplessTransferTx( + params: SignGrouplessTransferTxParams + ): Promise[]> { + const data = this.buildGrouplessTransferTxParams(params) + const response = await this.nodeProvider.groupless.postGrouplessTransfer(data) + return response.map((result) => { + return { + ...this.convertTransferTxResult(result), + type: 'Transfer' as const + } + }) + } + + async buildGrouplessDeployContractTx( + params: SignGrouplessDeployContractTxParams + ): Promise[]> { + const data = this.buildGrouplessDeployContractTxParams(params) + const response = await this.nodeProvider.groupless.postGrouplessDeployContract(data) + const transferTxs = response.transferTxs.map((result) => ({ + ...this.convertTransferTxResult(result), + type: 'Transfer' as const + })) + const deployContractTx = { + ...this.convertDeployContractTxResult(response.deployContractTx), + type: 'DeployContract' as const + } + return [...transferTxs, deployContractTx] + } + + async buildGrouplessExecuteScriptTx( + params: SignGrouplessExecuteScriptTxParams + ): Promise[]> { + const data = this.buildGrouplessExecuteScriptTxParams(params) + const response = await this.nodeProvider.groupless.postGrouplessExecuteScript(data) + const transferTxs = response.transferTxs.map((result) => ({ + ...this.convertTransferTxResult(result), + type: 'Transfer' as const + })) + const executeScriptTx = { + ...this.convertExecuteScriptTxResult(response.executeScriptTx), + type: 'ExecuteScript' as const + } + return [...transferTxs, executeScriptTx] + } + static buildUnsignedTx(params: SignUnsignedTxParams): Omit { const unsignedTxBin = hexToBinUnsafe(params.unsignedTx) const decoded = unsignedTxCodec.decode(unsignedTxBin) @@ -182,6 +231,41 @@ export abstract class TransactionBuilder { } } + private buildGrouplessTransferTxParams(params: SignGrouplessTransferTxParams): node.BuildGrouplessTransferTx { + return { + fromAddress: params.fromAddress, + destinations: toApiDestinations(params.destinations), + gasPrice: toApiNumber256Optional(params.gasPrice), + targetBlockHash: params.targetBlockHash + } + } + + private buildGrouplessDeployContractTxParams(params: SignGrouplessDeployContractTxParams): node.BuildGrouplessDeployContractTx { + return { + fromAddress: params.fromAddress, + bytecode: params.bytecode, + initialAttoAlphAmount: toApiNumber256Optional(params.initialAttoAlphAmount), + initialTokenAmounts: toApiTokens(params.initialTokenAmounts), + issueTokenAmount: toApiNumber256Optional(params.issueTokenAmount), + issueTokenTo: params.issueTokenTo, + gasPrice: toApiNumber256Optional(params.gasPrice), + targetBlockHash: params.targetBlockHash + } + } + + + private buildGrouplessExecuteScriptTxParams(params: SignGrouplessExecuteScriptTxParams): node.BuildGrouplessExecuteScriptTx { + return { + fromAddress: params.fromAddress, + bytecode: params.bytecode, + attoAlphAmount: toApiNumber256Optional(params.attoAlphAmount), + tokens: toApiTokens(params.tokens), + gasPrice: toApiNumber256Optional(params.gasPrice), + targetBlockHash: params.targetBlockHash, + gasEstimationMultiplier: params.gasEstimationMultiplier + } + } + private buildDeployContractTxParams( params: SignDeployContractTxParams, publicKey: string diff --git a/packages/web3/src/signer/types.ts b/packages/web3/src/signer/types.ts index 61130db2a..b89913000 100644 --- a/packages/web3/src/signer/types.ts +++ b/packages/web3/src/signer/types.ts @@ -18,6 +18,7 @@ along with the library. If not, see . import { Number256, Token } from '../api' import { node } from '../api' +import { SimulationResult } from '../api/api-alephium' import { Eq, assertType, NetworkId } from '../utils' export type Address = string @@ -33,7 +34,7 @@ export interface Destination { } assertType> -export type KeyType = 'default' | 'bip340-schnorr' +export type KeyType = 'default' | 'bip340-schnorr' | 'groupless' export interface Account { keyType: KeyType @@ -113,7 +114,7 @@ export interface SignExecuteScriptTxResult { signature: string gasAmount: number gasPrice: Number256 - simulatedOutputs: node.Output[] + simulationResult: SimulationResult } assertType< Eq< @@ -159,6 +160,39 @@ export type SignChainedTxResult = | SignDeployContractChainedTxResult | SignExecuteScriptChainedTxResult +export interface SignGrouplessTransferTxParams { + fromAddress: string + destinations: Destination[] + gasPrice?: Number256 + targetBlockHash?: string +} +assertType>() +export interface SignGrouplessDeployContractTxParams { + fromAddress: string + bytecode: string + initialAttoAlphAmount?: Number256 + initialTokenAmounts?: Token[] + issueTokenAmount?: Number256 + issueTokenTo?: string + gasPrice?: Number256 + targetBlockHash?: string +} +assertType>() +export interface SignGrouplessExecuteScriptTxParams { + fromAddress: string + bytecode: string + attoAlphAmount?: Number256 + tokens?: Token[] + gasPrice?: Number256 + targetBlockHash?: string + gasEstimationMultiplier?: number +} +assertType>() +export type SignGrouplessTxParams = + | SignGrouplessTransferTxParams + | SignGrouplessDeployContractTxParams + | SignGrouplessExecuteScriptTxParams + export type MessageHasher = | 'alephium' // Message is prefixed with 'Alephium signed message: ' before hashed with blake2b | 'sha256' diff --git a/packages/web3/src/utils/sign.test.ts b/packages/web3/src/utils/sign.test.ts index 19e2a58f8..c4fc35a7a 100644 --- a/packages/web3/src/utils/sign.test.ts +++ b/packages/web3/src/utils/sign.test.ts @@ -33,6 +33,17 @@ describe('Signing', function () { expect(verifySignature(hash, publicKey, signature, 'default')).toEqual(true) }) + it('shoud sign and verify secp256k1 signature with groupless address', () => { + const ec = new EC.ec('secp256k1') + const key = ec.genKeyPair() + const privateKey = key.getPrivate().toString('hex', 64) + const publicKey = publicKeyFromPrivateKey(privateKey, 'groupless') + + const hash = '8fc5f0d120b730f97f6cea5f02ae4a6ee7bf451d9261c623ea69d85e870201d2' + const signature = sign(hash, privateKey, 'groupless') + expect(verifySignature(hash, publicKey, signature, 'groupless')).toEqual(true) + }) + it('should sign and verify schnorr signature', () => { const ec = new EC.ec('secp256k1') const key = ec.genKeyPair() diff --git a/packages/web3/src/utils/sign.ts b/packages/web3/src/utils/sign.ts index 7d1c30ad2..b612dedc6 100644 --- a/packages/web3/src/utils/sign.ts +++ b/packages/web3/src/utils/sign.ts @@ -40,7 +40,7 @@ necc.utils.hmacSha256Sync = (key: Uint8Array, ...messages: Uint8Array[]): Uint8A export function sign(hash: string, privateKey: string, _keyType?: KeyType): string { const keyType = _keyType ?? 'default' - if (keyType === 'default') { + if (keyType === 'default' || keyType === 'groupless') { const key = ec.keyFromPrivate(privateKey) const signature = key.sign(hash) return encodeSignature(signature) @@ -54,7 +54,7 @@ export function verifySignature(hash: string, publicKey: string, signature: stri const keyType = _keyType ?? 'default' try { - if (keyType === 'default') { + if (keyType === 'default' || keyType === 'groupless') { const key = ec.keyFromPublic(publicKey, 'hex') return key.verify(hash, signatureDecode(ec, signature)) } else { From 4e8adbecdb6c02e83bdadfdd8308ecaa2e4a46d2 Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Thu, 13 Feb 2025 16:25:45 +0100 Subject: [PATCH 02/10] Update openapi.json --- packages/web3/src/api/api-alephium.ts | 29 --------------------------- 1 file changed, 29 deletions(-) diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index 30855cb10..d7a6acb3d 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -322,7 +322,6 @@ export interface BuildExecuteScriptTxResult { /** BuildGrouplessDeployContractTx */ export interface BuildGrouplessDeployContractTx { - /** @format address */ fromAddress: string /** @format hex-string */ bytecode: string @@ -347,7 +346,6 @@ export interface BuildGrouplessDeployContractTxResult { /** BuildGrouplessExecuteScriptTx */ export interface BuildGrouplessExecuteScriptTx { - /** @format address */ fromAddress: string /** @format hex-string */ bytecode: string @@ -370,7 +368,6 @@ export interface BuildGrouplessExecuteScriptTxResult { /** BuildGrouplessTransferTx */ export interface BuildGrouplessTransferTx { - /** @format address */ fromAddress: string destinations: Destination[] /** @format uint256 */ @@ -3843,32 +3840,6 @@ export class Api extends HttpClient - this.request< - Balance, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout - >({ - path: `/groupless/${address}/balance`, - method: 'GET', - query: query, - format: 'json', - ...params }).then(convertHttpResponse) } } From 4a5170d140a9ab355af85ab9648399d81445e94a Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Thu, 13 Feb 2025 23:34:01 +0100 Subject: [PATCH 03/10] Support explicit groupIndex for groupless address --- packages/web3/src/address/address.test.ts | 87 ++++++++++++++--------- packages/web3/src/address/address.ts | 64 ++++++++++++++--- packages/web3/src/contract/ralph.ts | 15 +--- packages/web3/src/signer/tx-builder.ts | 9 ++- 4 files changed, 118 insertions(+), 57 deletions(-) diff --git a/packages/web3/src/address/address.test.ts b/packages/web3/src/address/address.test.ts index 2cb2bb2f1..918d54849 100644 --- a/packages/web3/src/address/address.test.ts +++ b/packages/web3/src/address/address.test.ts @@ -65,7 +65,19 @@ describe('address', function () { ).toThrow('Invalid multisig address, n: 2, m: 3') expect(() => validateAddress('thebear')).toThrow('Invalid multisig address') expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBeUndefined() - expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8Bdjfv')).toThrow('Invalid checksum for P2PK address:') + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@0')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toBeUndefined() + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8Bdjfv')).toThrow( + 'Invalid checksum for P2PK address:' + ) + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@4')).toThrow( + 'Invalid group index: 4' + ) + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@j')).toThrow( + 'Invalid group index: j' + ) }) it('should return if an address is valid', () => { @@ -79,6 +91,12 @@ describe('address', function () { expect( isValidAddress('2jW1n2icPtc55Cdm8TF9FjGH681cWthsaZW3gaUFekFZepJoeyY3ZbY7y5SCtAjyCjLL24c4L2Vnfv3KDdAypCddfAY') ).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@j')).toEqual(false) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@4')).toEqual(false) }) it('should get address type', () => { @@ -103,30 +121,35 @@ describe('address', function () { }) it('should calculate the group of addresses', () => { - expect(groupOfAddress('15EM5rGtt7dPRZScE4Z9oL2EDfj84JnoSgq3NNgdcGFyu')).toBe(0), - expect(groupOfAddress('1D59jXR9NpD9ZQqZTRVcVbKVh6ko5TUMt89WvkA8P9P7w')).toBe(1), - expect(groupOfAddress('14tAT3nm7UqVP7gZ35icSdT3AEffv1kaUUMbWQK5PFygr')).toBe(2), - expect(groupOfAddress('12F5aVQoQ7cNrgsVN2YPciwYvwmtJp4ohLa2x4R5KgLbG')).toBe(3), - expect( - groupOfAddress('2jW1n2icPtc55Cdm8TF9FjGH681cWthsaZW3gaUFekFZepJoeyY3ZbY7y5SCtAjyCjLL24c4L2Vnfv3KDdAypCddfAY') - ).toBe(0), - expect( - groupOfAddress('2jXboVD9p66wrAHkPHx2AQocAzYXUWeppmRT3PuVT3ccxX9u8puTnwLeQ2VbTd4sNkgSEgk1cLbyVGLFshGweJCk1Mr') - ).toBe(1), - expect( - groupOfAddress('2je1yvQHpg8bKCDmvr1koELSNbty5DHrHYRkXomiRNvP5VcsZTK3WisBco2sCtCULM2YbxRxPd7QwhdP2hz9PEQwB1S') - ).toBe(2), - expect( - groupOfAddress('2jWukVCejM4Zifz9LvMG4dfR6SEecHLX8VqbswhGwnu61d28B861UhLu3ZmTHu4N14m1kk9rbxreBYzcxta1WPawKzG') - ).toBe(3), - expect(groupOfAddress('eBrjfQNeyUCuxE4zpbfMZcbS3PuvbMJDQBCyk4HRHtX4')).toBe(0), - expect(groupOfAddress('euWxyF55nGTxavL6mgGeMrFdvSRzHor8AmhgPXm8Lm9D')).toBe(1), - expect(groupOfAddress('n2pYTzmA27tkp7UNFPhMJpjz3jr5vgessxqJ7kwomBMF')).toBe(2), - expect(groupOfAddress('tLf6hDfrUugmxZhKxGoZMpAUBt3NcZ2hrTspTCmZ6JdQ')).toBe(3), - expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kj')).toBe(0), - expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kk')).toBe(1), - expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9km')).toBe(2), - expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kn')).toBe(3) + expect(groupOfAddress('15EM5rGtt7dPRZScE4Z9oL2EDfj84JnoSgq3NNgdcGFyu')).toBe(0) + expect(groupOfAddress('1D59jXR9NpD9ZQqZTRVcVbKVh6ko5TUMt89WvkA8P9P7w')).toBe(1) + expect(groupOfAddress('14tAT3nm7UqVP7gZ35icSdT3AEffv1kaUUMbWQK5PFygr')).toBe(2) + expect(groupOfAddress('12F5aVQoQ7cNrgsVN2YPciwYvwmtJp4ohLa2x4R5KgLbG')).toBe(3) + expect( + groupOfAddress('2jW1n2icPtc55Cdm8TF9FjGH681cWthsaZW3gaUFekFZepJoeyY3ZbY7y5SCtAjyCjLL24c4L2Vnfv3KDdAypCddfAY') + ).toBe(0) + expect( + groupOfAddress('2jXboVD9p66wrAHkPHx2AQocAzYXUWeppmRT3PuVT3ccxX9u8puTnwLeQ2VbTd4sNkgSEgk1cLbyVGLFshGweJCk1Mr') + ).toBe(1) + expect( + groupOfAddress('2je1yvQHpg8bKCDmvr1koELSNbty5DHrHYRkXomiRNvP5VcsZTK3WisBco2sCtCULM2YbxRxPd7QwhdP2hz9PEQwB1S') + ).toBe(2) + expect( + groupOfAddress('2jWukVCejM4Zifz9LvMG4dfR6SEecHLX8VqbswhGwnu61d28B861UhLu3ZmTHu4N14m1kk9rbxreBYzcxta1WPawKzG') + ).toBe(3) + expect(groupOfAddress('eBrjfQNeyUCuxE4zpbfMZcbS3PuvbMJDQBCyk4HRHtX4')).toBe(0) + expect(groupOfAddress('euWxyF55nGTxavL6mgGeMrFdvSRzHor8AmhgPXm8Lm9D')).toBe(1) + expect(groupOfAddress('n2pYTzmA27tkp7UNFPhMJpjz3jr5vgessxqJ7kwomBMF')).toBe(2) + expect(groupOfAddress('tLf6hDfrUugmxZhKxGoZMpAUBt3NcZ2hrTspTCmZ6JdQ')).toBe(3) + expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kj')).toBe(0) + expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kk')).toBe(1) + expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9km')).toBe(2) + expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kn')).toBe(3) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBe(2) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@0')).toBe(0) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toBe(1) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toBe(2) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toBe(3) }) it('should calculate the group of lockup script', () => { @@ -154,7 +177,7 @@ describe('address', function () { const publicKeyLike = new Uint8Array([0x00, ...bytes4]) const checkSum = intAs4BytesCodec.encode(djb2(publicKeyLike)) const scriptHint = djb2(bytes4) | 1 - const p2pk: LockupScript = { kind: 'P2PK', value: { type: 0, publicKey: bytes4, scriptHint, checkSum} } + const p2pk: LockupScript = { kind: 'P2PK', value: { type: 0, publicKey: bytes4, scriptHint, checkSum } } const p2pkAddress = bs58.encode(new Uint8Array([0x04, 0x00, ...bytes4, ...checkSum])) expect(groupOfAddress(p2pkAddress)).toBe(groupOfLockupScript(p2pk)) }) @@ -192,12 +215,12 @@ describe('address', function () { expect(addressFromPublicKey('030f9f042a9410969f1886f85fa20f6e43176ae23fc5e64db15b3767c84c5db2dc')).toBe( '1ACCkgFfmTif46T3qK12znuWjb5Bk9jXpqaeWt2DXx8oc' ) - expect(addressFromPublicKey('029592852f5d289785904b89a073ff80ee6155c894b1d13ecb16bcf3ac02473e1a', 'groupless')).toBe( - '3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK' - ) - expect(addressFromPublicKey('aecfc38a48f5fe7e050fca59de9f8d77fa7a7d9e63af608a95f8839de397f48a', 'bip340-schnorr')).toBe( - 'qvegNNcKFBtkMcZTLj42pki2YDYTvHaGyBxBaWrPaHwj' - ) + expect( + addressFromPublicKey('029592852f5d289785904b89a073ff80ee6155c894b1d13ecb16bcf3ac02473e1a', 'groupless') + ).toBe('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK') + expect( + addressFromPublicKey('aecfc38a48f5fe7e050fca59de9f8d77fa7a7d9e63af608a95f8839de397f48a', 'bip340-schnorr') + ).toBe('qvegNNcKFBtkMcZTLj42pki2YDYTvHaGyBxBaWrPaHwj') }) it('should convert between contract id and address', () => { diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index 1ed083a17..d3e02f033 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -54,8 +54,7 @@ export function isValidAddress(address: string): boolean { } function decodeAndValidateAddress(address: string): Uint8Array { - // TODO: Need to consider groupless address with @group - const decoded = base58ToBytes(address) + const decoded = addressToBytes(address) if (decoded.length === 0) throw new Error('Address is empty') const addressType = decoded[0] if (addressType === AddressType.P2MPKH) { @@ -78,14 +77,15 @@ function decodeAndValidateAddress(address: string): Uint8Array { // [type, ...hash] if (decoded.length === 33) return decoded } else if (addressType === AddressType.P2PK) { - // [type, keyType, ...publicKey, ...checkSum] - if (decoded.length === 39) { - const publicKeyLikeBytes = decoded.slice(1, 35) // Include the keyType byte + if (decoded.length === 43) { + // [type, keyType, ...publicKey, ...checkSum, ...scriptHint] + const publicKeyLikeBytes = decoded.slice(1, 35) const checksum = binToHex(decoded.slice(35, 39)) const expectedChecksum = binToHex(intAs4BytesCodec.encode(djb2(publicKeyLikeBytes))) if (checksum !== expectedChecksum) { throw new Error(`Invalid checksum for P2PK address: ${address}`) } + return decoded } } @@ -93,9 +93,36 @@ function decodeAndValidateAddress(address: string): Uint8Array { throw new Error(`Invalid address: ${address}`) } +export function addressToBytes(address: string): Uint8Array { + if (address.length > 2 && address[address.length - 2] === '@') { + const groupIndex = parseGroupIndex(address[address.length - 1]) + const decoded = base58ToBytes(address.slice(0, address.length - 2)) + if (decoded[0] === 0x04 && decoded.length === 39) { + const publicKeyBytes = decoded.slice(2, 35) + const scriptHint = findScriptHint(djb2(publicKeyBytes) | 1, groupIndex) + const scriptHintBytes = intAs4BytesCodec.encode(scriptHint) + return new Uint8Array([...decoded, ...scriptHintBytes]) + } + throw new Error(`Invalid groupless address: ${address}`) + } else { + const decoded = base58ToBytes(address) + if (decoded[0] === 0x04 && decoded.length === 39) { + const publicKeyBytes = decoded.slice(2, 35) + const scriptHintBytes = intAs4BytesCodec.encode(djb2(publicKeyBytes) | 1) + return new Uint8Array([...decoded, ...scriptHintBytes]) + } + return decoded + } +} + export function isAssetAddress(address: string) { const addressType = decodeAndValidateAddress(address)[0] - return addressType === AddressType.P2PKH || addressType === AddressType.P2MPKH || addressType === AddressType.P2SH || addressType === AddressType.P2PK + return ( + addressType === AddressType.P2PKH || + addressType === AddressType.P2MPKH || + addressType === AddressType.P2SH || + addressType === AddressType.P2PK + ) } export function isGrouplessAddress(address: string) { @@ -139,7 +166,7 @@ function groupOfP2mpkhAddress(address: Uint8Array): number { } function groupOfP2pkAddress(address: Uint8Array): number { - return groupFromBytes(address.slice(1, 34)) + return groupFromHint(intAs4BytesCodec.decode(address.slice(38, 42))) } // Pay to script hash address @@ -250,8 +277,7 @@ export function groupOfLockupScript(lockupScript: LockupScript): number { } else if (lockupScript.kind === 'P2SH') { return groupFromBytes(lockupScript.value) } else if (lockupScript.kind === 'P2PK') { - // FIXME: support @group for groupless address - return groupFromBytes(lockupScript.value.publicKey) + return groupFromHint(lockupScript.value.scriptHint) } else { // P2C const contractId = lockupScript.value @@ -261,6 +287,26 @@ export function groupOfLockupScript(lockupScript: LockupScript): number { export function groupFromBytes(bytes: Uint8Array): number { const hint = djb2(bytes) | 1 + return groupFromHint(hint) +} + +export function groupFromHint(hint: number): number { const hash = xorByte(hint) return hash % TOTAL_NUMBER_OF_GROUPS } + +function findScriptHint(hint: number, groupIndex: number): number { + if (groupFromHint(hint) === groupIndex) { + return hint + } else { + return findScriptHint(hint + 1, groupIndex) + } +} + +function parseGroupIndex(groupIndexStr: string): number { + const groupIndex = parseInt(groupIndexStr) + if (isNaN(groupIndex) || groupIndex < 0 || groupIndex >= TOTAL_NUMBER_OF_GROUPS) { + throw new Error(`Invalid group index: ${groupIndexStr}`) + } + return groupIndex +} diff --git a/packages/web3/src/contract/ralph.ts b/packages/web3/src/contract/ralph.ts index 2f51e9f16..7369df919 100644 --- a/packages/web3/src/contract/ralph.ts +++ b/packages/web3/src/contract/ralph.ts @@ -36,6 +36,7 @@ import { import { boolCodec } from '../codec/codec' import { TraceableError } from '../error' import djb2 from '../utils/djb2' +import { addressToBytes, groupFromHint } from '../address' export function encodeByteVec(hex: string): Uint8Array { if (!isHexString(hex)) { @@ -47,19 +48,7 @@ export function encodeByteVec(hex: string): Uint8Array { } export function encodeAddress(address: string): Uint8Array { - // Check if address has group suffix (e.g. "@0") - if (address.length > 2 && address[address.length - 2] === '@') { - throw new Error("TODO: support groupless address with @group") - } else { - const decoded = bs58.decode(address) - if (decoded[0] === 0x04 && decoded.length === 39) { - // If it is groupless address without @group, we need to add script hint - const publicKeyBytes = decoded.slice(2, 35) - const scriptHintBytes = intAs4BytesCodec.encode(djb2(publicKeyBytes) | 1) - return new Uint8Array([...decoded, ...scriptHintBytes]) - } - return decoded - } + return addressToBytes(address) } export enum VmValType { diff --git a/packages/web3/src/signer/tx-builder.ts b/packages/web3/src/signer/tx-builder.ts index ea6fce58e..6d649cb2e 100644 --- a/packages/web3/src/signer/tx-builder.ts +++ b/packages/web3/src/signer/tx-builder.ts @@ -240,7 +240,9 @@ export abstract class TransactionBuilder { } } - private buildGrouplessDeployContractTxParams(params: SignGrouplessDeployContractTxParams): node.BuildGrouplessDeployContractTx { + private buildGrouplessDeployContractTxParams( + params: SignGrouplessDeployContractTxParams + ): node.BuildGrouplessDeployContractTx { return { fromAddress: params.fromAddress, bytecode: params.bytecode, @@ -253,8 +255,9 @@ export abstract class TransactionBuilder { } } - - private buildGrouplessExecuteScriptTxParams(params: SignGrouplessExecuteScriptTxParams): node.BuildGrouplessExecuteScriptTx { + private buildGrouplessExecuteScriptTxParams( + params: SignGrouplessExecuteScriptTxParams + ): node.BuildGrouplessExecuteScriptTx { return { fromAddress: params.fromAddress, bytecode: params.bytecode, From c69d5a47db9a42f574c3a1a3cb9daa6cb1c95e7b Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Fri, 14 Feb 2025 11:03:01 +0100 Subject: [PATCH 04/10] Optional group param for contract deploy function --- packages/web3/src/address/address.ts | 6 +++++- packages/web3/src/contract/contract.ts | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index d3e02f033..c02a39fee 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -94,7 +94,7 @@ function decodeAndValidateAddress(address: string): Uint8Array { } export function addressToBytes(address: string): Uint8Array { - if (address.length > 2 && address[address.length - 2] === '@') { + if (hasExplicitGroupIndex(address)) { const groupIndex = parseGroupIndex(address[address.length - 1]) const decoded = base58ToBytes(address.slice(0, address.length - 2)) if (decoded[0] === 0x04 && decoded.length === 39) { @@ -295,6 +295,10 @@ export function groupFromHint(hint: number): number { return hash % TOTAL_NUMBER_OF_GROUPS } +export function hasExplicitGroupIndex(address: string): boolean { + return address.length > 2 && address[address.length - 2] === '@' +} + function findScriptHint(hint: number, groupIndex: number): number { if (groupFromHint(hint) === groupIndex) { return hint diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index 73406237c..b32da0b0c 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -58,7 +58,7 @@ import { isHexString, hexToString } from '../utils' -import { contractIdFromAddress, groupOfAddress, addressFromContractId, subContractId } from '../address' +import { contractIdFromAddress, groupOfAddress, addressFromContractId, subContractId, isGrouplessAddress, hasExplicitGroupIndex } from '../address' import { getCurrentNodeProvider } from '../global' import { EventSubscribeOptions, EventSubscription, subscribeToEvents } from './events' import { MINIMAL_CONTRACT_DEPOSIT, ONE_ALPH, TOTAL_NUMBER_OF_GROUPS } from '../constants' @@ -590,7 +590,8 @@ export class Contract extends Artifact { async txParamsForDeployment

( signer: SignerProvider, - params: DeployContractParams

+ params: DeployContractParams

, + group?: number ): Promise { const isDevnet = await this.isDevnet(signer) const initialFields: Fields = params.initialFields ?? {} @@ -600,8 +601,16 @@ export class Contract extends Artifact { params.exposePrivateFunctions ?? false ) const selectedAccount = await signer.getSelectedAccount() + let signerAddress = selectedAccount.address + if (isGrouplessAddress(selectedAccount.address) && !hasExplicitGroupIndex(selectedAccount.address)) { + if (group === undefined) { + throw new Error('Groupless address requires a group number') + } + signerAddress = `${selectedAccount.address}@${group}` + } + const signerParams: SignDeployContractTxParams = { - signerAddress: selectedAccount.address, + signerAddress, signerKeyType: selectedAccount.keyType, bytecode: bytecode, initialAttoAlphAmount: params?.initialAttoAlphAmount, @@ -1079,11 +1088,12 @@ export abstract class ContractFactory): Promise> { + async deploy(signer: SignerProvider, deployParams: DeployContractParams, group?: number): Promise> { + const signerParams = await this.contract.txParamsForDeployment(signer, { ...deployParams, initialFields: addStdIdToFields(this.contract, deployParams.initialFields) - }) + }, group) const result = await signer.signAndSubmitDeployContractTx(signerParams) return { ...result, From 3f1488be8cd7924c3949e4f7dfd4a8a1a3837a2a Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Sat, 15 Feb 2025 22:13:56 +0100 Subject: [PATCH 05/10] Update the format of groupless address with explicit group index --- packages/web3/src/address/address.test.ts | 30 +++++++++++------------ packages/web3/src/address/address.ts | 2 +- packages/web3/src/contract/contract.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/web3/src/address/address.test.ts b/packages/web3/src/address/address.test.ts index 918d54849..c42a0e30e 100644 --- a/packages/web3/src/address/address.test.ts +++ b/packages/web3/src/address/address.test.ts @@ -65,17 +65,17 @@ describe('address', function () { ).toThrow('Invalid multisig address, n: 2, m: 3') expect(() => validateAddress('thebear')).toThrow('Invalid multisig address') expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@0')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/0')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toBeUndefined() expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8Bdjfv')).toThrow( 'Invalid checksum for P2PK address:' ) - expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@4')).toThrow( + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/4')).toThrow( 'Invalid group index: 4' ) - expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@j')).toThrow( + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/j')).toThrow( 'Invalid group index: j' ) }) @@ -92,11 +92,11 @@ describe('address', function () { isValidAddress('2jW1n2icPtc55Cdm8TF9FjGH681cWthsaZW3gaUFekFZepJoeyY3ZbY7y5SCtAjyCjLL24c4L2Vnfv3KDdAypCddfAY') ).toEqual(true) expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@j')).toEqual(false) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@4')).toEqual(false) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/j')).toEqual(false) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/4')).toEqual(false) }) it('should get address type', () => { @@ -146,10 +146,10 @@ describe('address', function () { expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9km')).toBe(2) expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kn')).toBe(3) expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBe(2) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@0')).toBe(0) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@1')).toBe(1) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@2')).toBe(2) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK@3')).toBe(3) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/0')).toBe(0) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toBe(1) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toBe(2) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toBe(3) }) it('should calculate the group of lockup script', () => { diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index c02a39fee..41f723295 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -296,7 +296,7 @@ export function groupFromHint(hint: number): number { } export function hasExplicitGroupIndex(address: string): boolean { - return address.length > 2 && address[address.length - 2] === '@' + return address.length > 2 && address[address.length - 2] === '/' } function findScriptHint(hint: number, groupIndex: number): number { diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index b32da0b0c..d2cec61b9 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -606,7 +606,7 @@ export class Contract extends Artifact { if (group === undefined) { throw new Error('Groupless address requires a group number') } - signerAddress = `${selectedAccount.address}@${group}` + signerAddress = `${selectedAccount.address}/${group}` } const signerParams: SignDeployContractTxParams = { From dfdfc0821b30dec7f4293d93e1c1d9e7b3296f07 Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Sun, 16 Feb 2025 19:24:35 +0100 Subject: [PATCH 06/10] Fix toApiAddress for groupless address --- packages/web3/src/api/types.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/web3/src/api/types.ts b/packages/web3/src/api/types.ts index 9088f8f1c..1ad2d0046 100644 --- a/packages/web3/src/api/types.ts +++ b/packages/web3/src/api/types.ts @@ -16,6 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with the library. If not, see . */ +import { hasExplicitGroupIndex } from '../address' import { ZERO_ADDRESS } from '../constants' import { isDebugModeEnabled } from '../debug' import { TraceableError } from '../error' @@ -99,14 +100,18 @@ export function toApiByteVec(v: Val): string { throw new Error(`Invalid hex-string: ${v}`) } -export function toApiAddress(v: Val): string { - if (typeof v === 'string') { +export function toApiAddress(v0: Val): string { + if (typeof v0 === 'string') { + let v = v0 + if (hasExplicitGroupIndex(v)) { + v = v.slice(0, -2) + } if (isBase58(v)) { - return v + return v0 } - throw new Error(`Invalid base58 string: ${v}`) + throw new Error(`Invalid base58 string: ${v0}`) } else { - throw new Error(`Invalid value: ${v}, expected a base58 string`) + throw new Error(`Invalid value: ${v0}, expected a base58 string`) } } From 1f91ea7b3997a214cf294d7a99c07d57ecb03d1b Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Mon, 17 Feb 2025 11:09:07 +0100 Subject: [PATCH 07/10] Use : as group index delimiter for groupless address --- packages/web3/src/address/address.test.ts | 30 +++++++++++------------ packages/web3/src/address/address.ts | 2 +- packages/web3/src/contract/contract.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/web3/src/address/address.test.ts b/packages/web3/src/address/address.test.ts index c42a0e30e..23f0a47c8 100644 --- a/packages/web3/src/address/address.test.ts +++ b/packages/web3/src/address/address.test.ts @@ -65,17 +65,17 @@ describe('address', function () { ).toThrow('Invalid multisig address, n: 2, m: 3') expect(() => validateAddress('thebear')).toThrow('Invalid multisig address') expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/0')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toBeUndefined() - expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:0')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:1')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:2')).toBeUndefined() + expect(validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:3')).toBeUndefined() expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8Bdjfv')).toThrow( 'Invalid checksum for P2PK address:' ) - expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/4')).toThrow( + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:4')).toThrow( 'Invalid group index: 4' ) - expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/j')).toThrow( + expect(() => validateAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:j')).toThrow( 'Invalid group index: j' ) }) @@ -92,11 +92,11 @@ describe('address', function () { isValidAddress('2jW1n2icPtc55Cdm8TF9FjGH681cWthsaZW3gaUFekFZepJoeyY3ZbY7y5SCtAjyCjLL24c4L2Vnfv3KDdAypCddfAY') ).toEqual(true) expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toEqual(true) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/j')).toEqual(false) - expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/4')).toEqual(false) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:1')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:2')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:3')).toEqual(true) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:j')).toEqual(false) + expect(isValidAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:4')).toEqual(false) }) it('should get address type', () => { @@ -146,10 +146,10 @@ describe('address', function () { expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9km')).toBe(2) expect(groupOfAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9kn')).toBe(3) expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toBe(2) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/0')).toBe(0) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/1')).toBe(1) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/2')).toBe(2) - expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK/3')).toBe(3) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:0')).toBe(0) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:1')).toBe(1) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:2')).toBe(2) + expect(groupOfAddress('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:3')).toBe(3) }) it('should calculate the group of lockup script', () => { diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index 41f723295..eba6545b5 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -296,7 +296,7 @@ export function groupFromHint(hint: number): number { } export function hasExplicitGroupIndex(address: string): boolean { - return address.length > 2 && address[address.length - 2] === '/' + return address.length > 2 && address[address.length - 2] === ':' } function findScriptHint(hint: number, groupIndex: number): number { diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index d2cec61b9..2cbbcbe2d 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -606,7 +606,7 @@ export class Contract extends Artifact { if (group === undefined) { throw new Error('Groupless address requires a group number') } - signerAddress = `${selectedAccount.address}/${group}` + signerAddress = `${selectedAccount.address}:${group}` } const signerParams: SignDeployContractTxParams = { From 79d36d232818a43f62d2af8602e8270cf14f948e Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Mon, 17 Feb 2025 11:13:20 +0100 Subject: [PATCH 08/10] Fix contract.test.ts --- test/contract.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/contract.test.ts b/test/contract.test.ts index 0cbd1bcac..dc5a89d00 100644 --- a/test/contract.test.ts +++ b/test/contract.test.ts @@ -451,14 +451,14 @@ describe('contract', function () { const test0 = OwnerOnly.tests.testOwner({ initialFields: { owner: parentAddress }, address: address, - callerAddress: randomContractAddress() + callerContractAddress: randomContractAddress() }) expectAssertionError(test0, address, 0) const test1 = await OwnerOnly.tests.testOwner({ initialFields: { owner: parentAddress }, address: address, - callerAddress: parentAddress + callerContractAddress: parentAddress }) // expectAssertionError(test2, address, 0) expect(test1.returns).toEqual(null) From 5a5730621e7d090e3937cfc8fc78a0e82b5258a4 Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Mon, 17 Feb 2025 20:56:46 +0100 Subject: [PATCH 09/10] Add groupless address util functions --- packages/web3/src/address/address.test.ts | 12 ++++++++- packages/web3/src/address/address.ts | 8 ++++++ packages/web3/src/contract/contract.ts | 31 ++++++++++++++++------- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/packages/web3/src/address/address.test.ts b/packages/web3/src/address/address.test.ts index 23f0a47c8..7b7acc2df 100644 --- a/packages/web3/src/address/address.test.ts +++ b/packages/web3/src/address/address.test.ts @@ -30,7 +30,9 @@ import { isContractAddress, isValidAddress, groupOfLockupScript, - isGrouplessAddress + isGrouplessAddress, + isGrouplessAddressWithGroupIndex, + isGrouplessAddressWithoutGroupIndex } from './address' import { binToHex, bs58 } from '../utils' import { randomBytes } from 'crypto' @@ -118,6 +120,14 @@ describe('address', function () { expect(isGrouplessAddress('vobthYg1e9tPKhmF96rpkv3akCj7vhvgPpsP4qwZqDw3')).toEqual(false) expect(isGrouplessAddress('qeKk7r92Vn2Xjn4GcMEcJ2EwVfVs27kWUpptrWcWsUWC')).toEqual(false) expect(() => isGrouplessAddress('yya86C6UemCeLs5Ztwjcf2Mp2Kkt4mwzzRpBiG6qQ9k')).toThrow('Invalid address:') + expect(isGrouplessAddressWithoutGroupIndex('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(true) + expect(isGrouplessAddressWithoutGroupIndex('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:1')).toEqual( + false + ) + expect(isGrouplessAddressWithoutGroupIndex('vobthYg1e9tPKhmF96rpkv3akCj7vhvgPpsP4qwZqDw3')).toEqual(false) + expect(isGrouplessAddressWithGroupIndex('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK:1')).toEqual(true) + expect(isGrouplessAddressWithGroupIndex('3cUqhqEgt8qFAokkD7qRsy9Q2Q9S1LEiSdogbBmaq7CnshB8BdjfK')).toEqual(false) + expect(isGrouplessAddressWithGroupIndex('vobthYg1e9tPKhmF96rpkv3akCj7vhvgPpsP4qwZqDw3')).toEqual(false) }) it('should calculate the group of addresses', () => { diff --git a/packages/web3/src/address/address.ts b/packages/web3/src/address/address.ts index eba6545b5..60fc73a2c 100644 --- a/packages/web3/src/address/address.ts +++ b/packages/web3/src/address/address.ts @@ -130,6 +130,14 @@ export function isGrouplessAddress(address: string) { return addressType === AddressType.P2PK } +export function isGrouplessAddressWithoutGroupIndex(address: string) { + return !hasExplicitGroupIndex(address) && isGrouplessAddress(address) +} + +export function isGrouplessAddressWithGroupIndex(address: string) { + return hasExplicitGroupIndex(address) && isGrouplessAddress(address) +} + export function isContractAddress(address: string) { const addressType = decodeAndValidateAddress(address)[0] return addressType === AddressType.P2C diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index 2cbbcbe2d..4fba99dfe 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -58,7 +58,13 @@ import { isHexString, hexToString } from '../utils' -import { contractIdFromAddress, groupOfAddress, addressFromContractId, subContractId, isGrouplessAddress, hasExplicitGroupIndex } from '../address' +import { + contractIdFromAddress, + groupOfAddress, + addressFromContractId, + subContractId, + isGrouplessAddressWithoutGroupIndex, +} from '../address' import { getCurrentNodeProvider } from '../global' import { EventSubscribeOptions, EventSubscription, subscribeToEvents } from './events' import { MINIMAL_CONTRACT_DEPOSIT, ONE_ALPH, TOTAL_NUMBER_OF_GROUPS } from '../constants' @@ -602,9 +608,9 @@ export class Contract extends Artifact { ) const selectedAccount = await signer.getSelectedAccount() let signerAddress = selectedAccount.address - if (isGrouplessAddress(selectedAccount.address) && !hasExplicitGroupIndex(selectedAccount.address)) { + if (isGrouplessAddressWithoutGroupIndex(selectedAccount.address)) { if (group === undefined) { - throw new Error('Groupless address requires a group number') + throw new Error('Groupless address requires explicit group number for contract deployment') } signerAddress = `${selectedAccount.address}:${group}` } @@ -1088,12 +1094,19 @@ export abstract class ContractFactory, group?: number): Promise> { - - const signerParams = await this.contract.txParamsForDeployment(signer, { - ...deployParams, - initialFields: addStdIdToFields(this.contract, deployParams.initialFields) - }, group) + async deploy( + signer: SignerProvider, + deployParams: DeployContractParams, + group?: number + ): Promise> { + const signerParams = await this.contract.txParamsForDeployment( + signer, + { + ...deployParams, + initialFields: addStdIdToFields(this.contract, deployParams.initialFields) + }, + group + ) const result = await signer.signAndSubmitDeployContractTx(signerParams) return { ...result, From 157307c0380a0c69b3dc4147cc0634cf780f29a7 Mon Sep 17 00:00:00 2001 From: h0ngcha0 Date: Mon, 17 Feb 2025 21:01:41 +0100 Subject: [PATCH 10/10] Use full node 3.12.0 --- .project.json | 2 +- artifacts/add/Add.ral.json | 2 +- artifacts/add/AddMain.ral.json | 2 +- artifacts/add/DestroyAdd.ral.json | 2 +- artifacts/greeter/Greeter.ral.json | 2 +- artifacts/greeter/GreeterMain.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest1.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest2.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest3.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest4.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest5.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest6.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest7.ral.json | 2 +- artifacts/nft/MintNFTTest.ral.json | 2 +- artifacts/nft/NFTCollectionTest.ral.json | 2 +- artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json | 2 +- artifacts/nft/NFTTest.ral.json | 2 +- artifacts/nft/NFTTestStd.ral.json | 2 +- artifacts/nft/WithdrawNFTCollectionTest.ral.json | 2 +- artifacts/nft/WrongNFTTest.ral.json | 2 +- artifacts/sub/Sub.ral.json | 2 +- artifacts/test/Assert.ral.json | 2 +- artifacts/test/CallScript0.ral.json | 2 +- artifacts/test/CallScript1.ral.json | 2 +- artifacts/test/Debug.ral.json | 2 +- artifacts/test/Deposit.ral.json | 2 +- artifacts/test/DepositToken.ral.json | 2 +- artifacts/test/InlineTest.ral.json | 2 +- artifacts/test/InsertIntoMap.ral.json | 2 +- artifacts/test/MapTest.ral.json | 2 +- artifacts/test/MapTestSub.ral.json | 2 +- artifacts/test/MapTestWrapper.ral.json | 2 +- artifacts/test/MetaData.ral.json | 2 +- artifacts/test/MultiDeposit.ral.json | 2 +- artifacts/test/MultiWithdraw.ral.json | 2 +- artifacts/test/OwnerOnly.ral.json | 2 +- artifacts/test/RemoveFromMap.ral.json | 2 +- artifacts/test/TemplateArrayVar.ral.json | 2 +- artifacts/test/TestAssert.ral.json | 2 +- artifacts/test/Transact.ral.json | 2 +- artifacts/test/UpdateMapValue.ral.json | 2 +- artifacts/test/UpdateUserAccount.ral.json | 2 +- artifacts/test/UserAccount.ral.json | 2 +- artifacts/test/Warnings.ral.json | 2 +- artifacts/test/Withdraw.ral.json | 2 +- artifacts/token/FakeTokenTest.ral.json | 2 +- artifacts/token/TokenTest.ral.json | 2 +- artifacts/token/TokenTestStd.ral.json | 2 +- docker/docker-compose.yml | 2 +- packages/cli/package.json | 2 +- packages/get-extension-wallet/package.json | 2 +- packages/walletconnect/package.json | 2 +- packages/web3-react/package.json | 2 +- packages/web3-test/package.json | 2 +- packages/web3-wallet/package.json | 2 +- packages/web3/package.json | 2 +- 56 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.project.json b/.project.json index 1d06b02c7..22c2037fc 100644 --- a/.project.json +++ b/.project.json @@ -1,5 +1,5 @@ { - "fullNodeVersion": "v3.10.0", + "fullNodeVersion": "v3.12.0", "compilerOptionsUsed": { "ignoreUnusedConstantsWarnings": false, "ignoreUnusedVariablesWarnings": false, diff --git a/artifacts/add/Add.ral.json b/artifacts/add/Add.ral.json index 01e0718de..08113d7a6 100644 --- a/artifacts/add/Add.ral.json +++ b/artifacts/add/Add.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Add", "bytecode": "0206124024404f407440a140af010002020205d34fbb20db1600160100020201000c0c0205d36a51f82d1600160100020200000202021805160016015f06160016015f075da00016002a16012aa100a000160016010e0dce00010002010304060011d319adf50e1300641600130164170517041603d1a21601160216041605c118010104060015d3f6ce55a6130064160013016417051704160316021340c8ac1603d1a21601160216041605c118010201010003d320f98f621600b0", "codeHash": "630de1d7741f1c7f5727b26fc099111ff2b96ca85388f013eb5e3ec1cb3cfcf9", diff --git a/artifacts/add/AddMain.ral.json b/artifacts/add/AddMain.ral.json index 861215aec..f2160a604 100644 --- a/artifacts/add/AddMain.ral.json +++ b/artifacts/add/AddMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "AddMain", "bytecodeTemplate": "0101030002000c{1}{2}17011700160016010e0e{0}01001818", "fieldsSig": { diff --git a/artifacts/add/DestroyAdd.ral.json b/artifacts/add/DestroyAdd.ral.json index df383fc52..7795fbc8c 100644 --- a/artifacts/add/DestroyAdd.ral.json +++ b/artifacts/add/DestroyAdd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DestroyAdd", "bytecodeTemplate": "01010300000005{1}0d0c{0}0105", "fieldsSig": { diff --git a/artifacts/greeter/Greeter.ral.json b/artifacts/greeter/Greeter.ral.json index 75f440506..538cec588 100644 --- a/artifacts/greeter/Greeter.ral.json +++ b/artifacts/greeter/Greeter.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Greeter", "bytecode": "190111010000000106d3952f757b030c7bce0002", "codeHash": "4bbf82c83dcb0a3df905c290fbc12a19ce5160a7b655c1a347913481da12d747", diff --git a/artifacts/greeter/GreeterMain.ral.json b/artifacts/greeter/GreeterMain.ral.json index 0baa21891..27c849f74 100644 --- a/artifacts/greeter/GreeterMain.ral.json +++ b/artifacts/greeter/GreeterMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "GreeterMain", "bytecodeTemplate": "01010300020014{0}17000c0d160001000d2f0c7b{0}17010c0d1601d4952f757b0d2f0c7b", "fieldsSig": { diff --git a/artifacts/nft/DeprecatedNFTTest1.ral.json b/artifacts/nft/DeprecatedNFTTest1.ral.json index d71fe2ddc..f3e09d008 100644 --- a/artifacts/nft/DeprecatedNFTTest1.ral.json +++ b/artifacts/nft/DeprecatedNFTTest1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest1", "bytecode": "02010e010000000103d3ee6a5cd5ce0102", "codeHash": "cc6928c9c6777077abcb5b9c4f7c5d620d6cae07ec6f00f5e8b0efe6a7b913c4", diff --git a/artifacts/nft/DeprecatedNFTTest2.ral.json b/artifacts/nft/DeprecatedNFTTest2.ral.json index 091b818e1..532b935fa 100644 --- a/artifacts/nft/DeprecatedNFTTest2.ral.json +++ b/artifacts/nft/DeprecatedNFTTest2.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest2", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000103d33e65d93dce0002", "codeHash": "ade9aee476ee752050a1e9e1b19039f05261cb3f53941152617174faf9eae572", diff --git a/artifacts/nft/DeprecatedNFTTest3.ral.json b/artifacts/nft/DeprecatedNFTTest3.ral.json index 399a0008b..17d6d4245 100644 --- a/artifacts/nft/DeprecatedNFTTest3.ral.json +++ b/artifacts/nft/DeprecatedNFTTest3.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest3", "bytecode": "02020e19010000000103d3ee6a5cd5ce0102010000000001d34d12f529", "codeHash": "465bc3739cd1649e58e0470971bd2fabf21363ab9fc2c15052fb2440dd06ada5", diff --git a/artifacts/nft/DeprecatedNFTTest4.ral.json b/artifacts/nft/DeprecatedNFTTest4.ral.json index bc24cab44..7702109f2 100644 --- a/artifacts/nft/DeprecatedNFTTest4.ral.json +++ b/artifacts/nft/DeprecatedNFTTest4.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest4", "bytecode": "02020e1b010000000103d3ee6a5cd5ce0102010000000103d35f9a418a0402", "codeHash": "a5de0fa0b3580303ac63423f09ce5ed95fccbf789679b32130a53c26fef182e9", diff --git a/artifacts/nft/DeprecatedNFTTest5.ral.json b/artifacts/nft/DeprecatedNFTTest5.ral.json index 84c7168f9..90c479ee7 100644 --- a/artifacts/nft/DeprecatedNFTTest5.ral.json +++ b/artifacts/nft/DeprecatedNFTTest5.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest5", "bytecode": "02020e1e010000000103d3ee6a5cd5ce0102010000000305d35c9ec8a3ce000c0c02", "codeHash": "8b1374f39db98c485af3dd05d0b0ce861e9528f290ca9dc0d7108e8b48b50161", diff --git a/artifacts/nft/DeprecatedNFTTest6.ral.json b/artifacts/nft/DeprecatedNFTTest6.ral.json index ad225ff74..20597339b 100644 --- a/artifacts/nft/DeprecatedNFTTest6.ral.json +++ b/artifacts/nft/DeprecatedNFTTest6.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest6", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000204d30e0a3ac10c0d02", "codeHash": "8bc0d39f0607d4a771ec70ae1057b71dbcde404177cb3b25fd7d93d553a2b8cd", diff --git a/artifacts/nft/DeprecatedNFTTest7.ral.json b/artifacts/nft/DeprecatedNFTTest7.ral.json index 307078453..b4d75cb2e 100644 --- a/artifacts/nft/DeprecatedNFTTest7.ral.json +++ b/artifacts/nft/DeprecatedNFTTest7.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DeprecatedNFTTest7", "bytecode": "02020e1d010000000103d3ee6a5cd5ce0102010000000204d3289dd321ce000b02", "codeHash": "b95c9acf088b090f5d9d34f28ab079cf22b9e53af8ae6864113c71172231ef4c", diff --git a/artifacts/nft/MintNFTTest.ral.json b/artifacts/nft/MintNFTTest.ral.json index 1f74a3db6..27eeb5b01 100644 --- a/artifacts/nft/MintNFTTest.ral.json +++ b/artifacts/nft/MintNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MintNFTTest", "bytecodeTemplate": "01010300000015{2}4c0ab413c40de0b6b3a7640000a2{1}0d0d{0}0107184a09b413c40de0b6b3a7640000a2{1}0d0d{0}010418", "fieldsSig": { diff --git a/artifacts/nft/NFTCollectionTest.ral.json b/artifacts/nft/NFTCollectionTest.ral.json index 819a035cc..6e28afd97 100644 --- a/artifacts/nft/NFTCollectionTest.ral.json +++ b/artifacts/nft/NFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "NFTCollectionTest", "bytecode": "04050912402d4040408a010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "087f9292bb326a4d39a6fac09928cb25edf2837718f830f3a166a937f8724779", diff --git a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json index e215ca01a..160bf29f0 100644 --- a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json +++ b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "NFTCollectionWithRoyaltyTest", "bytecode": "06080912402d40404050405b406c40b6010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b0100020201061601ce032c1367102d0201010202000316001601a9010202020008b4ce02450f7b16001601a801030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "3b64d5e360566a4e4f568f773536a3ea74e66d12231aa44f19d2214ba87b38d6", diff --git a/artifacts/nft/NFTTest.ral.json b/artifacts/nft/NFTTest.ral.json index 661efae79..0bca712d0 100644 --- a/artifacts/nft/NFTTest.ral.json +++ b/artifacts/nft/NFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "NFTTest", "bytecode": "04020914010000000102ce0202010000000203ce00ce0102", "codeHash": "4897086210869e612d82995b765a447c5319a55a56e8a0c3c07b4d9ca81e15b1", diff --git a/artifacts/nft/NFTTestStd.ral.json b/artifacts/nft/NFTTestStd.ral.json index 77e100427..2c977dc82 100644 --- a/artifacts/nft/NFTTestStd.ral.json +++ b/artifacts/nft/NFTTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "NFTTestStd", "bytecode": "040309144020010000000102ce0202010000000203ce00ce0102010000000002d36811cfdd02", "codeHash": "b7ff3fa8dfacc7ae5edbabd6573d0699dffc5a0f07ad14023f682a201b7bce55", diff --git a/artifacts/nft/WithdrawNFTCollectionTest.ral.json b/artifacts/nft/WithdrawNFTCollectionTest.ral.json index 96c50481b..3354aa83a 100644 --- a/artifacts/nft/WithdrawNFTCollectionTest.ral.json +++ b/artifacts/nft/WithdrawNFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "WithdrawNFTCollectionTest", "bytecodeTemplate": "01010300000006b4{1}0e0c{0}0106", "fieldsSig": { diff --git a/artifacts/nft/WrongNFTTest.ral.json b/artifacts/nft/WrongNFTTest.ral.json index f8798487c..4ae5590ed 100644 --- a/artifacts/nft/WrongNFTTest.ral.json +++ b/artifacts/nft/WrongNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "WrongNFTTest", "bytecode": "04020917010000000102ce0202010000000206040c7bce00ce0102", "codeHash": "7dd2ed643a98b2a1a52a9b9e536fcdae60d961b583b8109f777d846bfdfcae8d", diff --git a/artifacts/sub/Sub.ral.json b/artifacts/sub/Sub.ral.json index 002f23247..72c1d2225 100644 --- a/artifacts/sub/Sub.ral.json +++ b/artifacts/sub/Sub.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Sub", "bytecode": "01011e01000202010dd321939f9e05160016015fa00016002a16012ba100a00002", "codeHash": "3461ebfaca02ad0a3f587a5b67a461c0cbd82d14261407b1d9277ed4ad129234", diff --git a/artifacts/test/Assert.ral.json b/artifacts/test/Assert.ral.json index 6df5452a2..99d60e2d0 100644 --- a/artifacts/test/Assert.ral.json +++ b/artifacts/test/Assert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Assert", "bytecode": "000110010000000006d362d460120d0e2f0f7b", "codeHash": "46dc5e3835be6551dacbf81565912ec67575aa77522312ceed88472817735d6b", diff --git a/artifacts/test/CallScript0.ral.json b/artifacts/test/CallScript0.ral.json index 29e77a721..b78218e32 100644 --- a/artifacts/test/CallScript0.ral.json +++ b/artifacts/test/CallScript0.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "CallScript0", "bytecodeTemplate": "01010000000206{1}0d0e{0}010302", "fieldsSig": { diff --git a/artifacts/test/CallScript1.ral.json b/artifacts/test/CallScript1.ral.json index 8c39a2dc1..f2ab80697 100644 --- a/artifacts/test/CallScript1.ral.json +++ b/artifacts/test/CallScript1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "CallScript1", "bytecodeTemplate": "0101000000070a{1}0d0e{0}01030c11{2}010202", "fieldsSig": { diff --git a/artifacts/test/Debug.ral.json b/artifacts/test/Debug.ral.json index 5b7866138..bee9cc6af 100644 --- a/artifacts/test/Debug.ral.json +++ b/artifacts/test/Debug.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Debug", "bytecode": "00010b010000000001d38681d619", "codeHash": "cc0e1966e6847f2c03384e78df1dcd9a0c2b5db1b7c1e901d66e26e2b000eb2c", diff --git a/artifacts/test/Deposit.ral.json b/artifacts/test/Deposit.ral.json index 09a05094f..0ccacb564 100644 --- a/artifacts/test/Deposit.ral.json +++ b/artifacts/test/Deposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Deposit", "bytecodeTemplate": "01010300000007b413c40de0b6b3a7640000a20c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/DepositToken.ral.json b/artifacts/test/DepositToken.ral.json index abd7541db..88fa8e64a 100644 --- a/artifacts/test/DepositToken.ral.json +++ b/artifacts/test/DepositToken.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "DepositToken", "bytecodeTemplate": "01010300000009b4{1}{2}a3{2}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/InlineTest.ral.json b/artifacts/test/InlineTest.ral.json index 7cb8debab..488aa4212 100644 --- a/artifacts/test/InlineTest.ral.json +++ b/artifacts/test/InlineTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "InlineTest", "bytecode": "0101402b010100000112d3811965ccb413c32386f26fc10000a9a0000d2aa100a00018a0000d2aa100a00018a00002", "codeHash": "5ce5376e13ecf0b46e03923f50782b844e8bb099c8d3ab2cf6d8d3484c9150ed", diff --git a/artifacts/test/InsertIntoMap.ral.json b/artifacts/test/InsertIntoMap.ral.json index a345cdb52..e48f0381e 100644 --- a/artifacts/test/InsertIntoMap.ral.json +++ b/artifacts/test/InsertIntoMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "InsertIntoMap", "bytecodeTemplate": "01010300020010{2}{3}17011700{1}d10f2ca2{1}160016010f0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/MapTest.ral.json b/artifacts/test/MapTest.ral.json index 7ae760aab..c17f25ab5 100644 --- a/artifacts/test/MapTest.ral.json +++ b/artifacts/test/MapTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MapTest", "bytecode": "0004405c40dc4153418001030303001fd3a9cdcc691600d1a2140a5f5f6d61705f5f305f5f160047441601b11602d202011600d1a2140a5f5f6d61705f5f315f5f16014044b11602d201011600d1a2140a5f5f6d61705f5f325f5f1402001144b11602d2010101000104004036d3c50ed2bb0c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116020d2a0c0e0c140a5f5f6d61705f5f305f5f16004744cb010216020d2a0c0e0c140a5f5f6d61705f5f315f5f16014044cb010216020d2a0c0e0c140a5f5f6d61705f5f325f5f1402001144cb01020100010400402dd392ac08660c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116000d0c140a5f5f6d61705f5f305f5f16004744cb010316000d0c140a5f5f6d61705f5f315f5f16014044cb010316000d0c140a5f5f6d61705f5f325f5f1402001144cb0103010001020212d3143f7dc50c0d0d140a5f5f6d61705f5f305f5f16004744cb1701160101000c0d0d1601010102", "codeHash": "9c0dad73dd47255270a366794f84539f06816e30c68b1f1cca767707fa8db596", diff --git a/artifacts/test/MapTestSub.ral.json b/artifacts/test/MapTestSub.ral.json index f6553709e..07d1ff1e6 100644 --- a/artifacts/test/MapTestSub.ral.json +++ b/artifacts/test/MapTestSub.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MapTestSub", "bytecode": "0101404601030307014023d3cef11f5a14046d61703a160047441703130064130064170517041600d1a21603ce0016041605c117061600d10f2ca21600160116020f0c16060100160602", "codeHash": "755ebb4ca4c436991cc8363fedb6840abf16857a6c326983376db9e68fe8c985", diff --git a/artifacts/test/MapTestWrapper.ral.json b/artifacts/test/MapTestWrapper.ral.json index 002180752..a16a836c2 100644 --- a/artifacts/test/MapTestWrapper.ral.json +++ b/artifacts/test/MapTestWrapper.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MapTestWrapper", "bytecode": "01031d4030404301030303000dd3a9cdcc691600d10f2ca21600160116020f0cce000100010001010006d3c50ed2bb16000d0cce000101010001010006d392ac086616000d0cce000102", "codeHash": "1d525d3e4cbd1c8f4c0431bf6881e888eeebae012a14532530097f62dd766e9a", diff --git a/artifacts/test/MetaData.ral.json b/artifacts/test/MetaData.ral.json index eb38f7e90..a09f82597 100644 --- a/artifacts/test/MetaData.ral.json +++ b/artifacts/test/MetaData.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MetaData", "bytecode": "000319402c4033010300000006d38d0b3636b4b413c40de0b6b3a7640000a702000200000004b413c40de0b6b3a7640000a80200000000000102", "codeHash": "5b113459525557465f1cc5aeee453dfd5823d1a6094372cee6067f7466b40896", diff --git a/artifacts/test/MultiDeposit.ral.json b/artifacts/test/MultiDeposit.ral.json index 02815cc9b..f32348b3f 100644 --- a/artifacts/test/MultiDeposit.ral.json +++ b/artifacts/test/MultiDeposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MultiDeposit", "bytecodeTemplate": "0101030002004024{0}{1}17011700b413c40de0b6b3a7640000a20c0c16000100b413c40de0b6b3a7640000a20c0c16010100b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16000102b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16010102", "fieldsSig": { diff --git a/artifacts/test/MultiWithdraw.ral.json b/artifacts/test/MultiWithdraw.ral.json index fb2f23ac7..ae52da202 100644 --- a/artifacts/test/MultiWithdraw.ral.json +++ b/artifacts/test/MultiWithdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "MultiWithdraw", "bytecodeTemplate": "01010300020016{0}{1}170117000c0c160001010c0c1601010113c40de0b6b3a76400000d0c1600010313c40de0b6b3a76400000d0c16010103", "fieldsSig": { diff --git a/artifacts/test/OwnerOnly.ral.json b/artifacts/test/OwnerOnly.ral.json index 578c0ef9e..9ad2f7ecc 100644 --- a/artifacts/test/OwnerOnly.ral.json +++ b/artifacts/test/OwnerOnly.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "OwnerOnly", "bytecode": "010111010000000006d3bf853dbdb4ce00450c7b", "codeHash": "c8ecfd7b7e1f3d0169d80e0abb59702516eeff301d47e0e7be70a631bd9414ca", diff --git a/artifacts/test/RemoveFromMap.ral.json b/artifacts/test/RemoveFromMap.ral.json index b8cbe826b..639438e3a 100644 --- a/artifacts/test/RemoveFromMap.ral.json +++ b/artifacts/test/RemoveFromMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "RemoveFromMap", "bytecodeTemplate": "01010300000005{1}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/TemplateArrayVar.ral.json b/artifacts/test/TemplateArrayVar.ral.json index 391c6795a..be9192a17 100644 --- a/artifacts/test/TemplateArrayVar.ral.json +++ b/artifacts/test/TemplateArrayVar.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "TemplateArrayVar", "bytecodeTemplate": "010103000e00408d{1}{2}{3}{4}1703170217011700{6}{7}{8}170617051704{0}18{5}1816030f2f16020e2f1a16010d2f1a16000c2f1a0c7b160016011708170716070c2f16080d2f1a0c7b16021603170a170916090e2f160a0f2f1a0c7b16060e2f16050d2f1a16040c2f1a0c7b0c170b160b0e314c40260c170c160c0e314c1b160b7a0e314d0e2c160c7a0e314d2a78160b0e2c160c2a2f0c7b160c0d2a170c4a21160b0d2a170b4a7fd60c170d160d0f314c11160d7a0f314d102a78160d2f0c7b160d0d2a170d4a2b", "fieldsSig": { diff --git a/artifacts/test/TestAssert.ral.json b/artifacts/test/TestAssert.ral.json index bedfc284f..5bddfdd37 100644 --- a/artifacts/test/TestAssert.ral.json +++ b/artifacts/test/TestAssert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "TestAssert", "bytecodeTemplate": "010103000000040c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/Transact.ral.json b/artifacts/test/Transact.ral.json index c39b83b42..9711817a0 100644 --- a/artifacts/test/Transact.ral.json +++ b/artifacts/test/Transact.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Transact", "bytecode": "03064027404e40674080408e409c010100000009d353dbb7aab413c40de0b6b3a7640000a9a00013c40de0b6b3a76400002aa10002010200000009d3a248861cb413c40de0b6b3a7640000a8a00013c40de0b6b3a76400002ba1000201010101000ad3bf2d01bdb4ce001600aca00116002aa1010201020101000ad35496306fb4ce001600aba00116002ba10102010000000103d3815a8d0da00002010000000103d3a51b051ca00102", "codeHash": "0b6427253638fa8f32b04e7c5915d41d51b0148a8e219e4881eba5548a42ae41", diff --git a/artifacts/test/UpdateMapValue.ral.json b/artifacts/test/UpdateMapValue.ral.json index 667125fb9..3c73f5dde 100644 --- a/artifacts/test/UpdateMapValue.ral.json +++ b/artifacts/test/UpdateMapValue.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "UpdateMapValue", "bytecodeTemplate": "01010300000005{1}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UpdateUserAccount.ral.json b/artifacts/test/UpdateUserAccount.ral.json index 7a69d6049..c1642a631 100644 --- a/artifacts/test/UpdateUserAccount.ral.json +++ b/artifacts/test/UpdateUserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "UpdateUserAccount", "bytecodeTemplate": "01010300040015{1}{2}{3}{4}17031702170117001600160116021603100c{0}0100{5}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UserAccount.ral.json b/artifacts/test/UserAccount.ral.json index 3e2b3cf12..7aca88a2c 100644 --- a/artifacts/test/UserAccount.ral.json +++ b/artifacts/test/UserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "UserAccount", "bytecode": "080340284037404d010004040013d388b067e71600ce01410c7b1602ce02410c7b1601a1021603a103160116032aa101010001010003d3185a39e11600a100010000000507d384cc0995a001ce01a002ce02a00302", "codeHash": "4e9f7eac1b76eaa2268b5af6ebb5640252892dc170aad6c1ee7b639131a55816", diff --git a/artifacts/test/Warnings.ral.json b/artifacts/test/Warnings.ral.json index 19b0bcdcb..82821cef2 100644 --- a/artifacts/test/Warnings.ral.json +++ b/artifacts/test/Warnings.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Warnings", "bytecode": "02010c010002020002d31bbce4a602", "codeHash": "873e095edb39cdb4b11b1157003daeacad06d259a938cd270e22b8e89b75feea", diff --git a/artifacts/test/Withdraw.ral.json b/artifacts/test/Withdraw.ral.json index ac63d65e6..2ae75c0df 100644 --- a/artifacts/test/Withdraw.ral.json +++ b/artifacts/test/Withdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "Withdraw", "bytecodeTemplate": "010103000000040c0c{0}0101", "fieldsSig": { diff --git a/artifacts/token/FakeTokenTest.ral.json b/artifacts/token/FakeTokenTest.ral.json index 63b3678d6..518e4f31f 100644 --- a/artifacts/token/FakeTokenTest.ral.json +++ b/artifacts/token/FakeTokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "FakeTokenTest", "bytecode": "010509121b4024402f010000000103044d18010000000103044d18010000000103044d18010000000103044d18010000000001d38d0b3636", "codeHash": "52f971cb44d54a5353e94dc8db991d2726f76760af782e79bd8a66a9b5b294b7", diff --git a/artifacts/token/TokenTest.ral.json b/artifacts/token/TokenTest.ral.json index 417402fd2..945f148ed 100644 --- a/artifacts/token/TokenTest.ral.json +++ b/artifacts/token/TokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "TokenTest", "bytecode": "050409121b4024010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302", "codeHash": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd", diff --git a/artifacts/token/TokenTestStd.ral.json b/artifacts/token/TokenTestStd.ral.json index d6cacb113..ebadb8987 100644 --- a/artifacts/token/TokenTestStd.ral.json +++ b/artifacts/token/TokenTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.10.0", + "version": "v3.12.0", "name": "TokenTestStd", "bytecode": "050509121b40244030010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000002d36811cfdd02", "codeHash": "4aa5c769148cada8eeb1cd3791f6e793ed92009ac79ebb64dc79d4d7f2969c8b", diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ea822a3d0..ee2c71d94 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -29,7 +29,7 @@ services: condition: service_healthy alephium: - image: alephium/alephium:v3.10.0 + image: alephium/alephium:v3.12.0 restart: unless-stopped ports: - 19973:19973/tcp diff --git a/packages/cli/package.json b/packages/cli/package.json index d584f5451..43bbd07b0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/cli", - "version": "1.11.3", + "version": "1.12.0", "description": "Alephium command line tool", "license": "GPL", "repository": { diff --git a/packages/get-extension-wallet/package.json b/packages/get-extension-wallet/package.json index 69d4ae5ab..a52968739 100644 --- a/packages/get-extension-wallet/package.json +++ b/packages/get-extension-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/get-extension-wallet", - "version": "1.11.3", + "version": "1.12.0", "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { diff --git a/packages/walletconnect/package.json b/packages/walletconnect/package.json index 88cf69db4..24859b5f7 100644 --- a/packages/walletconnect/package.json +++ b/packages/walletconnect/package.json @@ -1,7 +1,7 @@ { "name": "@alephium/walletconnect-provider", "description": "Alephium Provider for WalletConnect Protocol", - "version": "1.11.3", + "version": "1.12.0", "author": "Alephium dev", "homepage": "https://github.com/alephium/walletconnect", "repository": { diff --git a/packages/web3-react/package.json b/packages/web3-react/package.json index 02798d9e9..f7187f771 100644 --- a/packages/web3-react/package.json +++ b/packages/web3-react/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/web3-react", - "version": "1.11.3", + "version": "1.12.0", "homepage": "https://github.com/alephium/alephium-web3-react", "license": "GPL", "description": "React components for Alephium Web3.", diff --git a/packages/web3-test/package.json b/packages/web3-test/package.json index 67161751f..3925d1baa 100644 --- a/packages/web3-test/package.json +++ b/packages/web3-test/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/web3-test", - "version": "1.11.3", + "version": "1.12.0", "description": "Utility functions for Alephium test", "keywords": [ "alephium", diff --git a/packages/web3-wallet/package.json b/packages/web3-wallet/package.json index 29f02d4ea..96c82c1d3 100644 --- a/packages/web3-wallet/package.json +++ b/packages/web3-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/web3-wallet", - "version": "1.11.3", + "version": "1.12.0", "description": "Simple wallets for Alephium", "keywords": [ "alephium", diff --git a/packages/web3/package.json b/packages/web3/package.json index 3a2fef5dc..ac0179707 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/web3", - "version": "1.11.3", + "version": "1.12.0", "description": "A JS/TS library to interact with the Alephium platform", "license": "GPL", "main": "dist/src/index.js",