diff --git a/agent/agent-base.ts b/agent/agent-base.ts index 0b20ed6a687..df19e4fd855 100644 --- a/agent/agent-base.ts +++ b/agent/agent-base.ts @@ -30,6 +30,7 @@ export * from '@hackbg/into' export * from '@hackbg/hide' export * from '@hackbg/many' export * from '@hackbg/4mat' +export * from '@hackbg/dump' export type Name = string diff --git a/agent/agent-chain.ts b/agent/agent-chain.ts index aa7f4ecaefd..45295505139 100644 --- a/agent/agent-chain.ts +++ b/agent/agent-chain.ts @@ -24,7 +24,6 @@ import type { Uploadable } from './agent' import { Error, Console, into, prop, hideProperties as hide, randomBytes } from './agent-base' -import type * as Mocknet from './agent-mocknet' /** A chain can be in one of the following modes: */ export enum ChainMode { @@ -207,22 +206,16 @@ export abstract class Chain { } /** @returns a devnet instance of this chain. */ static devnet (options: Partial = {}): Chain { - return new (this as any)({ - ...options.devnet ? { id: options.devnet.chainId, url: options.devnet.url.toString() } : {}, - ...options, - mode: Chain.Mode.Devnet - }) + options = { ...options, mode: Chain.Mode.Devnet } + if (options.devnet) { + options.id = options.devnet.chainId + options.url = options.devnet.url.toString() + } + return new (this as any)(options) } /** @returns a mocknet instance of this chain. */ - static mocknet (options?: Partial): Mocknet.Chain { - // this method is replaced in the root of the package - throw new Error('stub. try with `new Mocknet()`') - } - /** Async functions that return Chain instances in different modes. - * Values for `FADROMA_CHAIN` environment variable. - * Populated by @fadroma/connect. */ - static variants: ChainRegistry = { - Mocknet: (...args) => this.mocknet(...args) + static mocknet (options?: Partial): Chain { + throw new Error('Mocknet is not enabled for this chain.') } } /** @returns the chain of a thing diff --git a/agent/agent-services.ts b/agent/agent-services.ts index e61f7b4105b..6e531206a11 100644 --- a/agent/agent-services.ts +++ b/agent/agent-services.ts @@ -16,8 +16,7 @@ along with this program. If not, see . **/ import type { - Address, TxHash, ChainId, Agent, ClientClass, Hashed, CodeId, Deployment, Class, CodeHash, - Mocknet + Address, TxHash, ChainId, Agent, ClientClass, Hashed, CodeId, Deployment, Class, CodeHash, Chain, } from './agent' import { Error, Console, pluralize, bold, hideProperties } from './agent-base' import { Client, fetchCodeHash, getSourceSpecifier } from './agent-client' @@ -140,12 +139,13 @@ export class Uploader { /** Upload an Uploadable (such as a Contract or Template). * @returns Promise */ async upload (contract: Uploadable & Partial): Promise { + type Mocknet = Chain & { uploads: Record } if (contract.codeId) { this.log.log('found code id', contract.codeId) if (this.reupload) { this.log.log('reuploading because reupload is set') } else if (this.agent?.chain?.isMocknet && contract.codeHash) { - const { codeHash } = (this.agent.chain as Mocknet.Chain).uploads[contract.codeId] || {} + const { codeHash } = (this.agent.chain as Mocknet).uploads[contract.codeId] || {} if (codeHash === contract.codeHash) return contract as Uploaded this.log.log('reuploading because mocknet is not stateful yet') } else { @@ -159,7 +159,7 @@ export class Uploader { if (this.reupload) { this.log.log('reuploading because reupload is set') } else if (this.agent?.chain?.isMocknet) { - const { codeHash } = (this.agent.chain as Mocknet.Chain).uploads[cached.codeId] || {} + const { codeHash } = (this.agent.chain as Mocknet).uploads[cached.codeId] || {} if (codeHash === contract.codeHash) return cached this.log.log('reuploading because mocknet is not stateful yet') } else { diff --git a/agent/agent.ts b/agent/agent.ts index c68cb1105b8..e9cb5331d2b 100644 --- a/agent/agent.ts +++ b/agent/agent.ts @@ -24,12 +24,3 @@ export * from './agent-token' export * from './agent-client' export * from './agent-deploy' export * from './agent-services' -export * as Mocknet from './agent-mocknet' - -// This is here to prevent a circular dependency: -import { Chain } from './agent-chain' -import * as Mocknet from './agent-mocknet' -Chain.mocknet = (options: Partial = {}): Mocknet.Chain => new Mocknet.Chain({ - id: 'mocknet', - ...options -}) diff --git a/agent/package.json b/agent/package.json index 312a185fd4c..d43731c96d9 100644 --- a/agent/package.json +++ b/agent/package.json @@ -1,6 +1,6 @@ { "name": "@fadroma/agent", - "version": "1.1.2", + "version": "2.0.0-rc.0", "type": "module", "main": "agent.ts", "files": [ "*.ts", "**/*.ts" ], @@ -19,9 +19,7 @@ "@hackbg/logs": "workspace:^2.0.2", "@hackbg/many": "^1", "@hackbg/oops": "workspace:^1.1", - "@hackbg/over": "^1.1", - "@noble/secp256k1": "^2.0.0", - "@noble/ed25519": "^2.0.0" + "@hackbg/over": "^1.1" }, "devDependencies": { "@hackbg/ensuite": "^1.1" diff --git a/connect/connect.ts b/connect/connect.ts index 77a325150e3..c4d47af8f85 100644 --- a/connect/connect.ts +++ b/connect/connect.ts @@ -17,7 +17,7 @@ **/ import { - Console, Error, Chain, ChainMode, ChainId, Mocknet, bold, randomChainId + Console, Error, Chain, ChainMode, ChainId, bold, randomChainId } from '@fadroma/agent' import type { Agent, ChainRegistry } from '@fadroma/agent' import * as Scrt from '@fadroma/scrt' @@ -27,19 +27,11 @@ export * from '@fadroma/cw' import { Config } from '@hackbg/conf' import type { Environment } from '@hackbg/conf' -// Populate `Chain.variants` with catalog of possible connections: -Object.assign(Chain.variants as ChainRegistry, { - // Support for Secret Network - ScrtMainnet: Scrt.Chain.mainnet, - ScrtTestnet: Scrt.Chain.testnet, - // Devnet is injected here by @hackbg/fadroma -}) - export * from '@hackbg/conf' export * from '@fadroma/agent' -export { Scrt, Mocknet } +export { Scrt } export default function connect ( config: Partial = new ConnectConfig() @@ -48,10 +40,21 @@ export default function connect ( } export type ConnectMode = - |'Mocknet' // FIXME make chain-specific - |`Scrt${'Devnet'|'Testnet'|'Mainnet'}` + |`Scrt${'Mocknet'|'Devnet'|'Testnet'|'Mainnet'}` |`OKP4${'Devnet'|'Testnet'}` +export const connectModes: RecordChain> = { + // Support for Secret Network + ScrtMainnet: Scrt.mainnet, + ScrtTestnet: Scrt.testnet, + ScrtDevnet: () => { throw new Error('Devnets are only available via @hackbg/fadroma') }, + ScrtMocknet: Scrt.Chain.mocknet, + // Support for OKP4 + OKP4Testnet: CW.OKP4.testnet, + OKP4Devnet: () => { throw new Error('Devnets are only available via @hackbg/fadroma') }, + // TODO: Support for custom chain +} + /** Connection configuration. Factory for `Chain` and `Agent` objects. */ export class ConnectConfig extends Config { constructor ( @@ -68,10 +71,10 @@ export class ConnectConfig extends Config { protected getChainId () { const chainIds: Record = { - Mocknet: 'mocknet', ScrtDevnet: 'fadroma-devnet', ScrtTestnet: this.scrt.testnetChainId, ScrtMainnet: this.scrt.mainnetChainId, + ScrtMocknet: 'mocknet', OKP4Devnet: 'fadroma-devnet-okp4', OKP4Testnet: this.okp4.testnetChainId, } @@ -80,10 +83,10 @@ export class ConnectConfig extends Config { protected getChainMode () { const chainModes: Record = { - Mocknet: ChainMode.Mocknet, ScrtDevnet: ChainMode.Devnet, ScrtTestnet: ChainMode.Testnet, ScrtMainnet: ChainMode.Mainnet, + ScrtMocknet: ChainMode.Mocknet, OKP4Devnet: ChainMode.Devnet, OKP4Testnet: ChainMode.Testnet, } @@ -102,7 +105,7 @@ export class ConnectConfig extends Config { /** Name of stored mnemonic to use for authentication (currently devnet only) */ agentName: string = this.getString('FADROMA_AGENT', ()=>'Admin') /** Name of chain to use. */ - chain?: keyof ChainRegistry = this.getString('FADROMA_CHAIN', ()=>'Mocknet') + chain?: ConnectMode = this.getString('FADROMA_CHAIN', ()=>'ScrtMocknet') /** Override chain id. */ chainId?: ChainId /** Override chain mode. */ @@ -115,17 +118,17 @@ export class ConnectConfig extends Config { = this.getString('FADROMA_MNEMONIC', ()=>undefined) /** Create the Chain instance specified by the configuration. */ getChain ( - chainToGet: keyof ChainRegistry|ChainRegistry[keyof ChainRegistry]|undefined = this.chain + chainToGet: ConnectMode|((...args: any[])=>Chain)|undefined = this.chain ): C { if (!chainToGet) { chainToGet = this.chain if (!chainToGet) throw new Error.Missing.Chain() } if (typeof chainToGet === 'string') { // allow name to be passed - chainToGet = Chain.variants[chainToGet] + chainToGet = connectModes[chainToGet as ConnectMode] } if (!chainToGet) { // if still unspecified, throw - throw new ConnectError.UnknownChainSelected(this.chain!, Chain.variants) + throw new ConnectError.UnknownChainSelected(this.chain!, connectModes) } return chainToGet({ config: this }) as C // create Chain object } @@ -150,7 +153,7 @@ export class ConnectConfig extends Config { export class ConnectConsole extends Console { label = 'Fadroma Connect' - supportedChains (supportedChains: Record = Chain.variants) { + supportedChains (supportedChains: Record = connectModes) { this.br() this.info('Known chain names:') for (const chain of Object.keys(supportedChains).sort()) { diff --git a/connect/cw/cw-base.ts b/connect/cw/cw-base.ts index 221dfa55dc6..4fef6902d70 100644 --- a/connect/cw/cw-base.ts +++ b/connect/cw/cw-base.ts @@ -30,9 +30,12 @@ class CWConsole extends Console {} /** Generic CosmWasm-enabled chain. */ class CWChain extends Chain { + defaultDenom = '' + /** Query-only API handle. */ api?: CosmWasmClient + /** Async initialization. Populates the `api` property. */ get ready (): Promise { const init = new Promise(async (resolve, reject)=>{ @@ -48,6 +51,7 @@ class CWChain extends Chain { Object.defineProperty(this, 'ready', { get () { return init } }) return init } + } /** Generic agent for CosmWasm-enabled chains. */ diff --git a/connect/cw/okp4/okp4.ts b/connect/cw/okp4/okp4.ts index 7d208ca7d07..43500a36711 100644 --- a/connect/cw/okp4/okp4.ts +++ b/connect/cw/okp4/okp4.ts @@ -18,40 +18,26 @@ class OKP4Config extends Config { static defaultTestnetUrl: string = 'https://okp4-testnet-rpc.polkachu.com/' //'https://okp4-testnet-api.polkachu.com/' - constructor ( - options: Partial = {}, - environment?: Environment - ) { + constructor (options: Partial = {}, environment?: Environment) { super(environment) this.override(options) } testnetChainId: string = this.getString( 'FADROMA_OKP4_TESTNET_CHAIN_ID', - () => OKP4Config.defaultTestnetChainId) + () => OKP4Config.defaultTestnetChainId + ) testnetUrl: string = this.getString( 'FADROMA_OKP4_TESTNET_URL', - () => OKP4Config.defaultTestnetUrl) + () => OKP4Config.defaultTestnetUrl + ) + } /** OKP4 chain. */ class OKP4Chain extends Chain { - /** Default denomination of gas token. */ - static defaultDenom = 'uknow' - - /** @returns Fee in uscrt */ - static gas = (amount: Uint128|number) => new Fee(amount, this.defaultDenom) - - /** Set permissive fees by default. */ - static defaultFees: AgentFees = { - upload: this.gas(1000000), - init: this.gas(1000000), - exec: this.gas(1000000), - send: this.gas(1000000), - } - /** Default Agent class to use. */ declare Agent: AgentClass @@ -64,6 +50,7 @@ class OKP4Chain extends Chain { constructor (options: Partial & { config?: OKP4Config } = { config: new OKP4Config() }) { + console.log({options}) super(options) } @@ -105,6 +92,21 @@ class OKP4Chain extends Chain { const ids = Object.values(lawStoneCodeIds) return await getContractsById(this.id, api, LawStone, ids, map) } + + /** Default denomination of gas token. */ + static defaultDenom = 'uknow' + + /** @returns Fee in uscrt */ + static gas = (amount: Uint128|number) => new Fee(amount, this.defaultDenom) + + /** Set permissive fees by default. */ + static defaultFees: AgentFees = { + upload: this.gas(1000000), + init: this.gas(1000000), + exec: this.gas(1000000), + send: this.gas(1000000), + } + } async function getContractsById ( @@ -128,7 +130,9 @@ async function getContractsById ( const addresses = await api.getContracts(codeId) for (const address of addresses) { - const contract = new $C({ address, codeHash, codeId: String(codeId), } as Partial) + const contract = new $C( + { address, codeHash, codeId: String(codeId) } as Partial + ) contract.meta.chainId = chainId if (map) { (contracts as Map).set(address, contract) diff --git a/connect/cw/package.json b/connect/cw/package.json index 0dc9327c163..66d29b5c1c5 100644 --- a/connect/cw/package.json +++ b/connect/cw/package.json @@ -6,7 +6,7 @@ "files": [ "*.ts" ], "description": "CosmJS Stargate integration for Fadroma, incl. OKP4 support.", "dependencies": { - "@fadroma/agent": "workspace:1.1.2", + "@fadroma/agent": "workspace:2.0.0-rc.0", "@hackbg/conf": "workspace:3.1.5", "@hackbg/cosmjs-esm": "workspace:1.0.0-rc.31", "@noble/hashes": "^1.3.2", diff --git a/connect/package.json b/connect/package.json index f9385f25152..32391104311 100644 --- a/connect/package.json +++ b/connect/package.json @@ -1,6 +1,6 @@ { "name": "@fadroma/connect", - "version": "3.4.15-rc.7", + "version": "4.0.0-rc.0", "type": "module", "main": "./connect.ts", "files": [ "*.ts", "!cw", "!evm", "!scrt" ], @@ -10,7 +10,7 @@ "ubik": "pnpm check && ubik" }, "dependencies": { - "@fadroma/agent": "workspace:1.1.2", + "@fadroma/agent": "workspace:2.0.0-rc.0", "@fadroma/scrt": "workspace:10.1.10-rc.13", "@fadroma/cw": "workspace:0.6.0", "@hackbg/conf": "workspace:3.1.5" diff --git a/connect/scrt/package.json b/connect/scrt/package.json index 66559436364..a6233284095 100644 --- a/connect/scrt/package.json +++ b/connect/scrt/package.json @@ -6,9 +6,11 @@ "files": [ "*.ts" ], "description": "Fadroma support for Secret Network. Provides a SecretJS-based implementation of the base classes in @fadroma/agent to operate smart contracts on the Secret Network.", "dependencies": { - "@fadroma/agent": "workspace:1.1.2", - "@hackbg/conf": "workspace:3.1.5", - "@hackbg/secretjs-esm": "workspace:1.9.3-patch.26" + "@fadroma/agent": "workspace:2.0.0-rc.0", + "@hackbg/conf": "workspace:3.1.5", + "@hackbg/secretjs-esm": "workspace:1.9.3-patch.26", + "@noble/secp256k1": "^2.0.0", + "@noble/ed25519": "^2.0.0" }, "devDependencies": { "@hackbg/ensuite": "1.x" diff --git a/connect/scrt/scrt-chain.ts b/connect/scrt/scrt-chain.ts index 3050e69a889..bd95eb1e1a1 100644 --- a/connect/scrt/scrt-chain.ts +++ b/connect/scrt/scrt-chain.ts @@ -1,8 +1,9 @@ import * as SecretJS from '@hackbg/secretjs-esm' import { Config, Error, Console } from './scrt-base' +import * as Mocknet from './scrt-mocknet' import { Agent, Contract, assertAddress, into, base64, bip39, bip39EN, bold, - Chain, Fee, Mocknet, Bundle, assertChain + Chain, Fee, Bundle, assertChain } from '@fadroma/agent' import type { AgentClass, Built, Uploaded, AgentFees, ChainClass, Uint128, BundleClass, Client, @@ -12,12 +13,16 @@ import type { /** Represents a Secret Network API endpoint. */ class ScrtChain extends Chain { - /** The default SecretJS module. */ - static SecretJS: typeof SecretJS + /** Logger handle. */ log = new Console('Scrt') + /** Smallest unit of native token. */ defaultDenom: string = ScrtChain.defaultDenom + + /** The default SecretJS module. */ + static SecretJS: typeof SecretJS + /** The SecretJS module used by this instance. * You can set this to a compatible version of the SecretJS module * in order to use it instead of the one bundled with this package. @@ -25,6 +30,7 @@ class ScrtChain extends Chain { * constructed by the configured Scrt instance's getAgent method * will use the non-default SecretJS module. */ SecretJS = ScrtChain.SecretJS + /** The Agent class used by this instance. */ Agent: AgentClass = ScrtChain.Agent @@ -43,27 +49,33 @@ class ScrtChain extends Chain { get api () { return this.getApi() } + get block () { return this.api.then(api=>api.query.tendermint.getLatestBlock({})) } + get height () { return this.block.then(block=>Number(block.block?.header?.height)) } + async getBalance (denom = this.defaultDenom, address: Address) { const api = await this.api const response = await api.query.bank.balance({ address, denom }) return response.balance!.amount! } + async getLabel (contract_address: string): Promise { const api = await this.api const response = await api.query.compute.contractInfo({ contract_address }) return response.ContractInfo!.label! } + async getCodeId (contract_address: string): Promise { const api = await this.api const response = await api.query.compute.contractInfo({ contract_address }) return response.ContractInfo!.code_id! } + async getHash (arg: string|number): Promise { const api = await this.api if (typeof arg === 'number' || !isNaN(Number(arg))) { @@ -76,9 +88,11 @@ class ScrtChain extends Chain { })).code_hash! } } + async query (instance: Partial, query: Message): Promise { throw new Error('TODO: Scrt#query: use same method on agent') } + /** @returns a fresh instance of the anonymous read-only API client. */ async getApi ( options: Partial = {} @@ -87,6 +101,7 @@ class ScrtChain extends Chain { if (!options.url) throw new Error.Missing('api url') return await new (this.SecretJS.SecretNetworkClient)(options as SecretJS.CreateClientOptions) } + async fetchLimits (): Promise<{ gas: number }> { const params = { subspace: "baseapp", key: "BlockParams" } const { param } = await (await this.api).query.params.params(params) @@ -146,9 +161,9 @@ class ScrtChain extends Chain { }) as ScrtChain /** Connect to a Secret Network mocknet. */ - static mocknet = (options: Partial = {}): Mocknet.Chain => super.mocknet({ - id: 'scrt-mocknet', - ...options||{} + static mocknet = (options: Partial = {}): Mocknet.Chain => new Mocknet.Chain({ + id: 'mocknet', + ...options }) } diff --git a/agent/agent-mocknet.ts b/connect/scrt/scrt-mocknet.ts similarity index 98% rename from agent/agent-mocknet.ts rename to connect/scrt/scrt-mocknet.ts index 7c45997381d..44e41da2aaa 100644 --- a/agent/agent-mocknet.ts +++ b/connect/scrt/scrt-mocknet.ts @@ -1,6 +1,6 @@ /** - Fadroma Mocknet + Fadroma Mocknet for Secret Network Copyright (C) 2023 Hack.bg This program is free software: you can redistribute it and/or modify @@ -20,14 +20,14 @@ import type { AgentClass, Uint128, BundleClass, ExecOpts, Uploadable, Uploaded, - Address, CodeHash, ChainId, CodeId, Message, Client, Label, AnyContract, Instantiated -} from './agent' -import { Error as BaseError, Console as BaseConsole, bold, colors, into } from './agent-base' -import { Chain, ChainMode, Agent, Bundle, assertChain } from './agent-chain' -import { Contract } from './agent-deploy' - -import { randomBech32, sha256, base16, bech32 } from '@hackbg/4mat' -import { brailleDump } from '@hackbg/dump' + Address, CodeHash, ChainId, CodeId, Message, Label, AnyContract, Instantiated, +} from '@fadroma/agent' +import { + Client, randomBech32, sha256, base16, bech32, + brailleDump, Error as BaseError, Console as BaseConsole, bold, colors, into, + Chain, ChainMode, Agent, Bundle, assertChain, + Contract +} from '@fadroma/agent' import * as secp256k1 from '@noble/secp256k1' import * as ed25519 from '@noble/ed25519' @@ -933,3 +933,4 @@ export const Error = (()=>{ } return Object.assign(MocknetError, { Query: MocknetError_Query }) })() //MocknetError + diff --git a/fadroma.ts b/fadroma.ts index a7f99ba519c..43960749129 100644 --- a/fadroma.ts +++ b/fadroma.ts @@ -28,13 +28,13 @@ import { Devnet } from './fadroma-devnet' import { ProjectWizard, toolVersions } from './fadroma-wizard' import { + connectModes, Chain, ChainMode, Scrt, Deployment, DeployStore, Agent, AnyContract, Contract, Client, DeploymentState, Template, toInstanceReceipt, timestamp, bold, Console, Error, bip39, bip39EN } from '@fadroma/connect' - import * as Dock from '@hackbg/dock' import { CommandContext } from '@hackbg/cmds' import $, { @@ -92,7 +92,7 @@ export function getDevnet (options: Partial = {}) { } // This installs devnet as a selectable chain: -Chain.variants['ScrtDevnet'] = +connectModes['ScrtDevnet'] = (options: Partial = { platform: 'scrt_1.9' }): Scrt.Chain => new Config().getDevnet(options).getChain(Scrt.Chain as ChainClass) diff --git a/package.json b/package.json index 51c30191278..e421b638ff2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hackbg/fadroma", - "version": "1.5.11-rc.9", + "version": "2.0.0-rc.0", "repository": { "type": "git", "url": "https://github.com/hackbg/fadroma" }, "type": "module", "main": "fadroma.ts", @@ -64,8 +64,8 @@ }, "dependencies": { - "@fadroma/agent": "workspace:1.1.2", - "@fadroma/connect": "workspace:3.4.15-rc.7", + "@fadroma/agent": "workspace:2.0.0-rc.0", + "@fadroma/connect": "workspace:4.0.0-rc.0", "@hackbg/cmds": "workspace:3.0.7", "@hackbg/dock": "workspace:2", "@hackbg/file": "workspace:1.2.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbeb43922bf..bf9c3cb8c8c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,10 +5,10 @@ importers: .: dependencies: '@fadroma/agent': - specifier: workspace:1.1.2 + specifier: workspace:2.0.0-rc.0 version: link:agent '@fadroma/connect': - specifier: workspace:3.4.15-rc.7 + specifier: workspace:4.0.0-rc.0 version: link:connect '@hackbg/cmds': specifier: workspace:3.0.7 @@ -70,7 +70,7 @@ importers: version: 4.0.5 '@types/node': specifier: latest - version: 20.8.0 + version: 20.8.5 '@types/prettyjson': specifier: ^0.0.30 version: 0.0.30 @@ -134,12 +134,6 @@ importers: '@hackbg/over': specifier: ^1.1 version: link:../ensuite/toolbox/over - '@noble/ed25519': - specifier: ^2.0.0 - version: 2.0.0 - '@noble/secp256k1': - specifier: ^2.0.0 - version: 2.0.0 devDependencies: '@hackbg/ensuite': specifier: ^1.1 @@ -148,7 +142,7 @@ importers: connect: dependencies: '@fadroma/agent': - specifier: workspace:1.1.2 + specifier: workspace:2.0.0-rc.0 version: link:../agent '@fadroma/cw': specifier: workspace:0.6.0 @@ -163,7 +157,7 @@ importers: connect/cw: dependencies: '@fadroma/agent': - specifier: workspace:1.1.2 + specifier: workspace:2.0.0-rc.0 version: link:../../agent '@hackbg/conf': specifier: workspace:3.1.5 @@ -348,7 +342,7 @@ importers: connect/scrt: dependencies: '@fadroma/agent': - specifier: workspace:1.1.2 + specifier: workspace:2.0.0-rc.0 version: link:../../agent '@hackbg/conf': specifier: workspace:3.1.5 @@ -356,6 +350,12 @@ importers: '@hackbg/secretjs-esm': specifier: workspace:1.9.3-patch.26 version: link:secretjs-esm + '@noble/ed25519': + specifier: ^2.0.0 + version: 2.0.0 + '@noble/secp256k1': + specifier: ^2.0.0 + version: 2.0.0 devDependencies: '@hackbg/ensuite': specifier: 1.x @@ -737,7 +737,7 @@ importers: version: link:../../connect/scrt/secretjs-esm/ubik '@types/node': specifier: latest - version: 20.8.0 + version: 20.8.5 concurrently: specifier: 7.2.2 version: 7.2.2 @@ -755,7 +755,7 @@ importers: version: 5.1.3 vitepress: specifier: 1.0.0-alpha.10 - version: 1.0.0-alpha.10(@types/node@20.8.0) + version: 1.0.0-alpha.10(@types/node@20.8.5) ensuite/toolbox/4mat: dependencies: @@ -1943,7 +1943,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -1964,14 +1964,14 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@18.17.12)(ts-node@10.9.1) + jest-config: 29.7.0(@types/node@20.8.5)(ts-node@10.9.1) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -1999,7 +1999,7 @@ packages: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 jest-mock: 29.7.0 dev: true @@ -2026,7 +2026,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 18.17.12 + '@types/node': 20.8.5 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -2059,7 +2059,7 @@ packages: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.19 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -2147,7 +2147,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.17.12 + '@types/node': 20.8.5 '@types/yargs': 17.0.24 chalk: 4.1.2 dev: true @@ -2436,13 +2436,13 @@ packages: /@types/cors@2.8.13: resolution: {integrity: sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 dev: true /@types/docker-modem@3.0.3: resolution: {integrity: sha512-i1A2Etnav7uHizZ87vUf4EqwJehY3JOcTfBS0pGBlO+HQ0jg2lUMCaJRg9VQM8ldZkpYdIfsenxcTOCpwxPXEg==} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 '@types/ssh2': 1.11.13 dev: true @@ -2488,13 +2488,13 @@ packages: resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 18.17.12 + '@types/node': 20.8.5 dev: true /@types/graceful-fs@4.1.6: resolution: {integrity: sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 dev: true /@types/istanbul-lib-coverage@2.0.4: @@ -2562,7 +2562,7 @@ packages: /@types/karma@6.3.4: resolution: {integrity: sha512-aefuFcs4e4NAOi1Ue4AP9fR2TQv45NFpdaLXdg+3FxDDndk/4T6LoHRTmKtRVqkwtQPh5Ntc3CxsoOgzldAAfg==} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 log4js: 6.9.1 transitivePeerDependencies: - supports-color @@ -2610,8 +2610,10 @@ packages: /@types/node@20.5.7: resolution: {integrity: sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==} - /@types/node@20.8.0: - resolution: {integrity: sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==} + /@types/node@20.8.5: + resolution: {integrity: sha512-SPlobFgbidfIeOYlzXiEjSYeIJiOCthv+9tSQVpvk4PAdIIc+2SmjNVzWXk9t0Y7dl73Zdf+OgXKHX9XtkqUpw==} + dependencies: + undici-types: 5.25.3 dev: true /@types/object-hash@1.3.4: @@ -2633,7 +2635,7 @@ packages: /@types/prompts@2.4.2: resolution: {integrity: sha512-TwNx7qsjvRIUv/BCx583tqF5IINEVjCNqg9ofKHRlSoUHE62WBHrem4B1HGXcIrG511v29d1kJ9a/t2Esz7MIg==} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 kleur: 3.0.3 dev: true @@ -2833,7 +2835,7 @@ packages: vite: ^3.0.0 vue: ^3.2.25 dependencies: - vite: 3.2.7(@types/node@20.8.0) + vite: 3.2.7(@types/node@20.8.5) vue: 3.3.4 dev: true @@ -4607,7 +4609,7 @@ packages: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.13 - '@types/node': 18.17.12 + '@types/node': 20.8.5 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -6557,7 +6559,7 @@ packages: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1 @@ -6647,7 +6649,7 @@ packages: - supports-color dev: true - /jest-config@29.7.0(@types/node@18.17.12)(ts-node@10.9.1): + /jest-config@29.7.0(@types/node@20.8.5)(ts-node@10.9.1): resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -6662,7 +6664,7 @@ packages: '@babel/core': 7.22.11 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 babel-jest: 29.7.0(@babel/core@7.22.11) chalk: 4.1.2 ci-info: 3.8.0 @@ -6733,7 +6735,7 @@ packages: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 jest-mock: 29.7.0 jest-util: 29.7.0 dev: true @@ -6754,7 +6756,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.6 - '@types/node': 18.17.12 + '@types/node': 20.8.5 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -6805,7 +6807,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 jest-util: 29.7.0 dev: true @@ -6860,7 +6862,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -6891,7 +6893,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.2 @@ -6943,7 +6945,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -6968,7 +6970,7 @@ packages: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.17.12 + '@types/node': 20.8.5 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -6980,7 +6982,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -6989,7 +6991,7 @@ packages: resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 18.17.12 + '@types/node': 20.8.5 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -9818,6 +9820,10 @@ packages: which-boxed-primitive: 1.0.2 dev: true + /undici-types@5.25.3: + resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==} + dev: true + /universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} @@ -9931,7 +9937,7 @@ packages: fsevents: 2.3.3 dev: true - /vite@3.2.7(@types/node@20.8.0): + /vite@3.2.7(@types/node@20.8.5): resolution: {integrity: sha512-29pdXjk49xAP0QBr0xXqu2s5jiQIXNvE/xwd0vUizYT2Hzqe4BksNNoWllFVXJf4eLZ+UlVQmXfB4lWrc+t18g==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -9956,7 +9962,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.8.0 + '@types/node': 20.8.5 esbuild: 0.15.18 postcss: 8.4.28 resolve: 1.22.4 @@ -9965,7 +9971,7 @@ packages: fsevents: 2.3.3 dev: true - /vitepress@1.0.0-alpha.10(@types/node@20.8.0): + /vitepress@1.0.0-alpha.10(@types/node@20.8.5): resolution: {integrity: sha512-RGPU+YApj2jaYplAIJUe+2qlDks9FzPX1QGK+7NdGByeCCVZg6z9eYWjjvfvA/sgCtG3yeJE/4/jCwlv4Y8bVw==} hasBin: true dependencies: @@ -9976,7 +9982,7 @@ packages: '@vueuse/core': 9.13.0(vue@3.3.4) body-scroll-lock: 4.0.0-beta.0 shiki: 0.11.1 - vite: 3.2.7(@types/node@20.8.0) + vite: 3.2.7(@types/node@20.8.5) vue: 3.3.4 transitivePeerDependencies: - '@algolia/client-search' diff --git a/spec/CW.spec.ts.md b/spec/CW.spec.ts.md index 25d0b2f828c..217acc6ac6a 100644 --- a/spec/CW.spec.ts.md +++ b/spec/CW.spec.ts.md @@ -11,7 +11,9 @@ unified into a single package, `@hackbg/cosmjs-esm`. ## OKP4 support -In these tests, we'll connect to the OKP4 okp4. +In these tests, we'll connect to a local OKP4 devnet +managed by Fadroma on your local Docker installation. +(Make sure you can call `docker` without `sudo`!) ```typescript import { OKP4 } from '@fadroma/connect'