mirror of
https://github.com/wharfkit/session.git
synced 2026-07-21 10:02:11 +00:00
v1.0.0 (#5)
* The `ui` option is now required for the SessionKit * Split SessionKit initialization to both "args" and "options" * Move `onSignComplete` to after all signing ops finish * Allow restoring without serialized session The restore method can now be used by just providing an actor, permission, and chainId - and will pull the session data out of the storage adapter to restore. * Track and allow restoring a default account per-chain Each individual chain now tracks a `default` value within its serialized storage, and the `restore()` function can now accept just a chain ID to restore the default account for that chain. * Reapplied 4faab919a3154dc875279e54c3baf9448de7eefa * Version 1.0.0-beta1 * Moved all mock data to its own repository * Updating @wharfkit/mock-data and MOCK_DIR * Fixing ci-test * Updating @wharfkit/mock-data * Allow manually passing in ABIDef for use in Sessions * Version 1.0.0-beta2 * Version 1.0.0-beta3 * Renamed AbiProvider to ABICache since it's an extension of ESR * Better defined ABICacheInterface * Version 1.0.0-beta4 * Prevent uneeded get_info calls when resolving * Linting of tests * Adding tests for placeholder resolution * Adding test data for placeholder resolution * Unused test cleanup * Linting * Removing unused import * Version 1.0.0-beta5 * Replacing @greymass/eosio with @wharfkit/antelope * Version 1.0.0-beta6 * Cleanup of greymass/eosio continued * Version 1.0.0-beta7 * Fixed badge path * Removed internal ABICache and using @wharfkit/abicache * Updating contract kit and abicache to optimize ABI loading * Remove requirement of prefix on storage * Change `appName` from Name to a string Resolves #68 Still accept `NameType` as the parameter to maintain reverse compatibility with older versions and other app formats. * Migrated data to wharfkit/common * Adding test to ensure common chains can be passed * Updating wharfkit/common * Switching to `import type` for some @wharfkit/common elements * Added package description * Update README.md * Updated @wharfkit/common * Version 1.0.0-beta8 * Updating ABICache and Contract Kit * Updating ESR library * Version 1.0.0-beta9 * Dependency cleanup * Updating private key plugin * Version 1.0.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": ["lib/*", "node_modules/**"],
|
||||
"ignorePatterns": ["lib/*", "tests/*", "node_modules/**"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
|
||||
@@ -10,7 +10,7 @@ lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
|
||||
|
||||
.PHONY: test
|
||||
test: node_modules
|
||||
@TS_NODE_PROJECT='./test/tsconfig.json' \
|
||||
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
|
||||
${BIN}/mocha ${MOCHA_OPTS} ${TEST_FILES} --no-timeout --grep '$(grep)'
|
||||
|
||||
test/watch: node_modules
|
||||
@@ -28,13 +28,13 @@ coverage: build/coverage
|
||||
|
||||
.PHONY: ci-test
|
||||
ci-test: node_modules
|
||||
@TS_NODE_PROJECT='./test/tsconfig.json' \
|
||||
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
|
||||
${BIN}/nyc ${NYC_OPTS} --reporter=text \
|
||||
${BIN}/mocha ${MOCHA_OPTS} -R list ${TEST_FILES}
|
||||
|
||||
.PHONY: check
|
||||
check: node_modules
|
||||
@${BIN}/eslint src --ext .ts --max-warnings 0 --format unix && echo "Ok"
|
||||
@${BIN}/eslint src test --ext .ts --max-warnings 0 --format unix && echo "Ok"
|
||||
|
||||
.PHONY: format
|
||||
format: node_modules
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
# @wharfkit/session
|
||||
|
||||
[](https://github.com/wharfkit/session/actions/workflows/test.yml?query=branch%3Amain)
|
||||
[](https://github.com/wharfkit/session/actions/workflows/test.yml?query=branch%3Amaster)
|
||||
|
||||
###### Session Kit - An Antelope blockchain session management toolkit
|
||||
|
||||
Authenticate and persist sessions using blockchain accounts within JavaScript and TypeScript applications. Each session can be used to interact with smart contracts using the authenticated account.
|
||||
|
||||
## IN DEVELOPMENT
|
||||
|
||||
This library is in very early development and everything is subject to change.
|
||||
|
||||
The [`master`](https://github.com/wharfkit/session) branch will contain early release builds of the Session Kit and will be published under the `beta` tag on npm. The [`dev`](https://github.com/wharfkit/session/tree/dev) branch will be the staging area for the next release, and all pull requests should be made against [`dev`](https://github.com/wharfkit/session/tree/dev).
|
||||
|
||||
No releases have yet been published of any version. Refer to the WharfKit organization on npm for all releases:
|
||||
|
||||
https://www.npmjs.com/org/wharfkit
|
||||
|
||||
## Installation
|
||||
|
||||
The `@wharfkit/session` package is distributed as a module on [npm](https://www.npmjs.com/package/PACKAGE).
|
||||
The `@wharfkit/session` package is distributed on [npm](https://www.npmjs.com/package/@wharfkit/session).
|
||||
|
||||
```
|
||||
yarn add @wharfkit/session
|
||||
@@ -28,9 +18,7 @@ npm install --save @wharfkit/session
|
||||
|
||||
## Usage
|
||||
|
||||
TODO
|
||||
|
||||
See [unit tests](https://github.com/wharfkit/session/tree/main/test) for usage examples during early development.
|
||||
Please refer to the documentation on [wharfkit.com](https://dev.wharfkit-website.pages.dev/docs).
|
||||
|
||||
## Autodocs
|
||||
|
||||
@@ -41,9 +29,9 @@ See [unit tests](https://github.com/wharfkit/session/tree/main/test) for usage e
|
||||
|
||||
You need [Make](https://www.gnu.org/software/make/), [node.js](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install) installed.
|
||||
|
||||
**All development should be done based on the [dev](https://github.com/wharfkit/session/tree/dev) branch.**
|
||||
The [`master`](https://github.com/wharfkit/session) branch will contain production release builds of the Session Kit. The [`dev`](https://github.com/wharfkit/session/tree/dev) branch will be where all development is performed and act as the staging area for the next release. All pull requests should be made against [`dev`](https://github.com/wharfkit/session/tree/dev).
|
||||
|
||||
Clone the repository and run `make` to checkout all dependencies and build the project. The tests can be run using `make test` and can be continously tested during development with `make test/watch`.
|
||||
Clone the repository and run `make` to checkout all dependencies and build the project. The tests can be run using `make test` and can be continuously tested during development with `make test/watch`.
|
||||
|
||||
See the [Makefile](./Makefile) for other useful targets.
|
||||
|
||||
@@ -51,8 +39,8 @@ Before submitting a pull request make sure to run `make check` and `make format`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [@greymass/eosio](https://github.com/greymass/eosio): Core library to provide Antelope data types.
|
||||
- [eosio-signing-request](https://github.com/greymass/eosio-signing-request): Antelope Signing Request Protocol.
|
||||
- [@wharfkit/antelope](https://github.com/wharfkit/antelope): Core library to provide Antelope data types.
|
||||
- [@wharfkit/signing-request](https://github.com/wharfkit/signing-request): Signing request protocol for Antelope blockchains.
|
||||
- [pako](https://github.com/nodeca/pako): zlib javascript port, used to compress signing requests.
|
||||
|
||||
---
|
||||
|
||||
+12
-7
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@wharfkit/session",
|
||||
"description": "DESCRIPTION",
|
||||
"version": "0.5.1",
|
||||
"description": "Create account-based sessions, perform transactions, and allow users to login using Antelope-based blockchains.",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/wharfkit/session",
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/session.js",
|
||||
@@ -17,13 +17,15 @@
|
||||
"prepare": "make"
|
||||
},
|
||||
"dependencies": {
|
||||
"@greymass/eosio": "^0.6.10",
|
||||
"eosio-signing-request": "^2.5.3",
|
||||
"@wharfkit/abicache": "^1.1.1",
|
||||
"@wharfkit/antelope": "^0.7.3",
|
||||
"@wharfkit/common": "^1.1.0",
|
||||
"@wharfkit/signing-request": "^3.0.0",
|
||||
"pako": "^2.0.4",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@greymass/eosio": "^0.6.10"
|
||||
"@wharfkit/antelope": "^0.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
@@ -40,7 +42,10 @@
|
||||
"@types/node": "^18.7.18",
|
||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||
"@typescript-eslint/parser": "^5.20.0",
|
||||
"@wharfkit/wallet-plugin-privatekey": "^0.3.0-ui-13",
|
||||
"@wharfkit/contract": "^0.3.3",
|
||||
"@wharfkit/mock-data": "^1.0.1",
|
||||
"@wharfkit/transact-plugin-resource-provider": "^1.0.0-beta1",
|
||||
"@wharfkit/wallet-plugin-privatekey": "^1.0.0-beta1",
|
||||
"chai": "^4.3.4",
|
||||
"eslint": "^8.13.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
@@ -59,6 +64,6 @@
|
||||
"typedoc": "^0.23.14",
|
||||
"typedoc-plugin-mermaid": "^1.10.0",
|
||||
"typescript": "^4.1.2",
|
||||
"yarn-deduplicate": "^6.0.1"
|
||||
"yarn-deduplicate": "^6.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
import {ABI, API, APIClient, NameType} from '@greymass/eosio'
|
||||
import {AbiProvider} from 'eosio-signing-request'
|
||||
|
||||
/**
|
||||
* Given an APIClient instance, this class provides an AbiProvider interface for retrieving and caching ABIs.
|
||||
*/
|
||||
export class ABICache implements AbiProvider {
|
||||
readonly cache: Map<string, ABI> = new Map()
|
||||
readonly pending: Map<string, Promise<API.v1.GetAbiResponse>> = new Map()
|
||||
|
||||
constructor(readonly client: APIClient) {}
|
||||
|
||||
async getAbi(account: NameType): Promise<ABI> {
|
||||
const key = String(account)
|
||||
let record = this.cache.get(key)
|
||||
if (!record) {
|
||||
let getAbi = this.pending.get(key)
|
||||
if (!getAbi) {
|
||||
getAbi = this.client.v1.chain.get_abi(account)
|
||||
this.pending.set(key, getAbi)
|
||||
}
|
||||
const response = await getAbi
|
||||
this.pending.delete(key)
|
||||
if (response.abi) {
|
||||
record = ABI.from(response.abi)
|
||||
this.cache.set(key, record)
|
||||
} else {
|
||||
throw new Error(`ABI for ${key} could not be loaded.`)
|
||||
}
|
||||
}
|
||||
return record
|
||||
}
|
||||
|
||||
setAbi(account: NameType, abi: ABI) {
|
||||
const key = String(account)
|
||||
this.cache.set(key, abi)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
export * from './abi'
|
||||
export * from './kit'
|
||||
export * from './login'
|
||||
export * from './session'
|
||||
export * from './storage'
|
||||
export * from './transact'
|
||||
export * from './types'
|
||||
export * from './ui'
|
||||
export * from './utils'
|
||||
export * from './wallet'
|
||||
|
||||
+4
-2
@@ -6,5 +6,7 @@ import {SessionKit} from './index-module'
|
||||
export default SessionKit
|
||||
|
||||
// expose dependencies
|
||||
export * from 'eosio-signing-request'
|
||||
export * from '@greymass/eosio'
|
||||
export * from '@wharfkit/antelope'
|
||||
export * from '@wharfkit/abicache'
|
||||
export * from '@wharfkit/common'
|
||||
export * from '@wharfkit/signing-request'
|
||||
|
||||
+137
-56
@@ -5,7 +5,9 @@ import {
|
||||
NameType,
|
||||
PermissionLevel,
|
||||
PermissionLevelType,
|
||||
} from '@greymass/eosio'
|
||||
} from '@wharfkit/antelope'
|
||||
import {ChainDefinition} from '@wharfkit/common'
|
||||
import type {ChainDefinitionType, Fetch} from '@wharfkit/common'
|
||||
|
||||
import {
|
||||
AbstractLoginPlugin,
|
||||
@@ -19,10 +21,10 @@ import {BrowserLocalStorage, SessionStorage} from './storage'
|
||||
import {
|
||||
AbstractTransactPlugin,
|
||||
BaseTransactPlugin,
|
||||
TransactABIDef,
|
||||
TransactPlugin,
|
||||
TransactPluginsOptions,
|
||||
} from './transact'
|
||||
import {ChainDefinition, ChainDefinitionType, Fetch} from './types'
|
||||
import {WalletPlugin, WalletPluginLoginResponse, WalletPluginMetadata} from './wallet'
|
||||
import {UserInterface} from './ui'
|
||||
import {getFetch} from './utils'
|
||||
@@ -45,31 +47,36 @@ export interface LoginResult {
|
||||
|
||||
export interface RestoreArgs {
|
||||
chain: Checksum256Type
|
||||
actor: NameType
|
||||
permission: NameType
|
||||
walletPlugin: Record<string, any>
|
||||
actor?: NameType
|
||||
permission?: NameType
|
||||
walletPlugin?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface SessionKitArgs {
|
||||
appName: NameType
|
||||
chains: ChainDefinitionType[]
|
||||
ui: UserInterface
|
||||
walletPlugins: WalletPlugin[]
|
||||
}
|
||||
|
||||
export interface SessionKitOptions {
|
||||
abis?: TransactABIDef[]
|
||||
allowModify?: boolean
|
||||
appName: NameType
|
||||
chains: ChainDefinitionType[]
|
||||
expireSeconds?: number
|
||||
fetch?: Fetch
|
||||
loginPlugins?: LoginPlugin[]
|
||||
storage?: SessionStorage
|
||||
transactPlugins?: TransactPlugin[]
|
||||
transactPluginsOptions?: TransactPluginsOptions
|
||||
ui?: UserInterface
|
||||
walletPlugins: WalletPlugin[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a session from an account.
|
||||
*/
|
||||
export class SessionKit {
|
||||
readonly abis: TransactABIDef[] = []
|
||||
readonly allowModify: boolean = true
|
||||
readonly appName: Name
|
||||
readonly appName: string
|
||||
readonly chains: ChainDefinition[]
|
||||
readonly expireSeconds: number = 120
|
||||
readonly fetch: Fetch
|
||||
@@ -77,26 +84,28 @@ export class SessionKit {
|
||||
readonly storage: SessionStorage
|
||||
readonly transactPlugins: AbstractTransactPlugin[]
|
||||
readonly transactPluginsOptions: TransactPluginsOptions = {}
|
||||
readonly ui?: UserInterface
|
||||
readonly ui: UserInterface
|
||||
readonly walletPlugins: WalletPlugin[]
|
||||
|
||||
constructor(options: SessionKitOptions) {
|
||||
// Store options passed on the kit
|
||||
if (typeof options.allowModify !== 'undefined') {
|
||||
this.allowModify = options.allowModify
|
||||
}
|
||||
this.appName = Name.from(options.appName)
|
||||
this.chains = options.chains.map((chain) => ChainDefinition.from(chain))
|
||||
// Override default expireSeconds for all sessions if specified
|
||||
if (options.expireSeconds) {
|
||||
this.expireSeconds = options.expireSeconds
|
||||
}
|
||||
constructor(args: SessionKitArgs, options: SessionKitOptions = {}) {
|
||||
// Save the appName to the SessionKit instance
|
||||
this.appName = String(args.appName)
|
||||
// Map the chains provided to ChainDefinition instances
|
||||
this.chains = args.chains.map((chain) => ChainDefinition.from(chain))
|
||||
// Save the UserInterface instance to the SessionKit
|
||||
this.ui = args.ui
|
||||
// Establish default plugins for wallet flow
|
||||
this.walletPlugins = args.walletPlugins
|
||||
// Override fetch if provided
|
||||
if (options.fetch) {
|
||||
this.fetch = options.fetch
|
||||
} else {
|
||||
this.fetch = getFetch(options)
|
||||
}
|
||||
// Add any ABIs manually provided
|
||||
if (options.abis) {
|
||||
this.abis = [...options.abis]
|
||||
}
|
||||
// Establish default plugins for login flow
|
||||
if (options.loginPlugins) {
|
||||
this.loginPlugins = options.loginPlugins
|
||||
@@ -106,7 +115,7 @@ export class SessionKit {
|
||||
if (options.storage) {
|
||||
this.storage = options.storage
|
||||
} else {
|
||||
this.storage = new BrowserLocalStorage(this.appName.toString())
|
||||
this.storage = new BrowserLocalStorage()
|
||||
}
|
||||
// Establish default plugins for transact flow
|
||||
if (options.transactPlugins) {
|
||||
@@ -114,15 +123,18 @@ export class SessionKit {
|
||||
} else {
|
||||
this.transactPlugins = [new BaseTransactPlugin()]
|
||||
}
|
||||
// Store options passed on the kit
|
||||
if (typeof options.allowModify !== 'undefined') {
|
||||
this.allowModify = options.allowModify
|
||||
}
|
||||
// Override default expireSeconds for all sessions if specified
|
||||
if (options.expireSeconds) {
|
||||
this.expireSeconds = options.expireSeconds
|
||||
}
|
||||
// Establish default options for transact plugins
|
||||
if (options.transactPluginsOptions) {
|
||||
this.transactPluginsOptions = options.transactPluginsOptions
|
||||
}
|
||||
if (options.ui) {
|
||||
this.ui = options.ui
|
||||
}
|
||||
// Establish default plugins for wallet flow
|
||||
this.walletPlugins = options.walletPlugins
|
||||
}
|
||||
|
||||
getChainDefinition(id: Checksum256Type, override?: ChainDefinition[]): ChainDefinition {
|
||||
@@ -147,12 +159,6 @@ export class SessionKit {
|
||||
*/
|
||||
async login(options?: LoginOptions): Promise<LoginResult> {
|
||||
try {
|
||||
if (!this.ui) {
|
||||
throw new Error(
|
||||
'An instance of a UserInterface must be provided to utilize the login method.'
|
||||
)
|
||||
}
|
||||
|
||||
// Create LoginContext for this login request.
|
||||
const context = new LoginContext({
|
||||
appName: this.appName,
|
||||
@@ -289,9 +295,7 @@ export class SessionKit {
|
||||
session,
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (this.ui) {
|
||||
await this.ui.onError(error)
|
||||
}
|
||||
await this.ui.onError(error)
|
||||
throw new Error(error)
|
||||
}
|
||||
}
|
||||
@@ -326,7 +330,7 @@ export class SessionKit {
|
||||
|
||||
async restore(args?: RestoreArgs, options?: LoginOptions): Promise<Session | undefined> {
|
||||
// If no args were provided, attempt to default restore the session from storage.
|
||||
if (!args && this.storage) {
|
||||
if (!args) {
|
||||
const data = await this.storage.read('session')
|
||||
if (data) {
|
||||
args = JSON.parse(data)
|
||||
@@ -339,30 +343,79 @@ export class SessionKit {
|
||||
throw new Error('Either a RestoreArgs object or a Storage instance must be provided.')
|
||||
}
|
||||
|
||||
let serializedSession: SerializedSession
|
||||
|
||||
// Retrieve all sessions from storage
|
||||
const data = await this.storage.read('sessions')
|
||||
|
||||
if (data) {
|
||||
// If sessions exist, restore the session that matches the provided args
|
||||
const sessions = JSON.parse(data)
|
||||
if (args.actor && args.permission) {
|
||||
// If all args are provided, return exact match
|
||||
serializedSession = sessions.find((s: SerializedSession) => {
|
||||
return (
|
||||
args &&
|
||||
s.chain === args.chain &&
|
||||
s.actor === args.actor &&
|
||||
s.permission === args.permission
|
||||
)
|
||||
})
|
||||
} else {
|
||||
// If no actor/permission defined, return based on chain
|
||||
serializedSession = sessions.find((s: SerializedSession) => {
|
||||
return args && s.chain === args.chain && s.default
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// If no sessions were found, but the args contains all the data for a serialized session, use args
|
||||
if (args.actor && args.permission && args.walletPlugin) {
|
||||
serializedSession = {
|
||||
chain: args.chain,
|
||||
actor: args.actor,
|
||||
permission: args.permission,
|
||||
walletPlugin: {
|
||||
id: args.walletPlugin.id,
|
||||
data: args.walletPlugin.data,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
// Otherwise throw an error since we can't establish the session data
|
||||
throw new Error('No sessions found in storage. A wallet plugin must be provided.')
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure a WalletPlugin was found with the provided ID.
|
||||
const walletPlugin = this.walletPlugins.find((p) => {
|
||||
if (!args) {
|
||||
return false
|
||||
}
|
||||
return p.id === args.walletPlugin.id
|
||||
return p.id === serializedSession.walletPlugin.id
|
||||
})
|
||||
|
||||
if (!walletPlugin) {
|
||||
throw new Error(`No WalletPlugin found with the ID of: '${args.walletPlugin.id}'`)
|
||||
throw new Error(
|
||||
`No WalletPlugin found with the ID of: '${serializedSession.walletPlugin.id}'`
|
||||
)
|
||||
}
|
||||
|
||||
// If walletPlugin data was provided, set it on the walletPlugin instance.
|
||||
if (args.walletPlugin.data) {
|
||||
// Set the wallet data from the serialized session
|
||||
if (serializedSession.walletPlugin.data) {
|
||||
walletPlugin.data = serializedSession.walletPlugin.data
|
||||
}
|
||||
|
||||
// If walletPlugin data was provided by args, override
|
||||
if (args.walletPlugin && args.walletPlugin.data) {
|
||||
walletPlugin.data = args.walletPlugin.data
|
||||
}
|
||||
|
||||
// Create a new session from the provided args.
|
||||
const session = new Session(
|
||||
{
|
||||
chain: this.getChainDefinition(args.chain),
|
||||
chain: this.getChainDefinition(serializedSession.chain),
|
||||
permissionLevel: PermissionLevel.from({
|
||||
actor: args.actor,
|
||||
permission: args.permission,
|
||||
actor: serializedSession.actor,
|
||||
permission: serializedSession.permission,
|
||||
}),
|
||||
walletPlugin,
|
||||
},
|
||||
@@ -390,28 +443,55 @@ export class SessionKit {
|
||||
return sessions
|
||||
}
|
||||
|
||||
async persistSession(session: Session) {
|
||||
async persistSession(session: Session, setAsDefault = true) {
|
||||
// TODO: Allow disabling of session persistence via kit options
|
||||
|
||||
// If no storage exists, do nothing.
|
||||
if (!this.storage) {
|
||||
return
|
||||
}
|
||||
// Serialize and save the current session to storage.
|
||||
|
||||
// Serialize session passed in
|
||||
const serialized = session.serialize()
|
||||
|
||||
// Specify whether or not this is now the default for the given chain
|
||||
serialized.default = setAsDefault
|
||||
|
||||
// Set this as the current session for all chains
|
||||
this.storage.write('session', JSON.stringify(serialized))
|
||||
|
||||
// Add the current session to the list of sessions, preventing duplication.
|
||||
const existing = await this.storage.read('sessions')
|
||||
if (existing) {
|
||||
const sessions = JSON.parse(existing)
|
||||
const other = sessions.filter((s: Record<string, any>) => {
|
||||
return (
|
||||
!Checksum256.from(s.chain).equals(Checksum256.from(serialized.chain)) ||
|
||||
!Name.from(s.actor).equals(Name.from(serialized.actor)) ||
|
||||
!Name.from(s.permission).equals(Name.from(serialized.permission))
|
||||
)
|
||||
const stored = JSON.parse(existing)
|
||||
const sessions: SerializedSession[] = stored
|
||||
// Filter out any matching session to ensure no duplicates
|
||||
.filter((s: SerializedSession): boolean => {
|
||||
return (
|
||||
!Checksum256.from(s.chain).equals(Checksum256.from(serialized.chain)) ||
|
||||
!Name.from(s.actor).equals(Name.from(serialized.actor)) ||
|
||||
!Name.from(s.permission).equals(Name.from(serialized.permission))
|
||||
)
|
||||
})
|
||||
// Remove the default status from all other sessions for this chain
|
||||
.map((s: SerializedSession): SerializedSession => {
|
||||
if (session.chain.id.equals(s.chain)) {
|
||||
s.default = false
|
||||
}
|
||||
return s
|
||||
})
|
||||
|
||||
// Merge arrays
|
||||
const orderedSessions = [...sessions, serialized]
|
||||
|
||||
// Sort sessions by chain, actor, and permission
|
||||
orderedSessions.sort((a: SerializedSession, b: SerializedSession) => {
|
||||
const chain = String(a.chain).localeCompare(String(b.chain))
|
||||
const actor = String(a.actor).localeCompare(String(b.actor))
|
||||
const permission = String(a.permission).localeCompare(String(b.permission))
|
||||
return chain || actor || permission
|
||||
})
|
||||
const orderedSessions = [...other, serialized]
|
||||
// TODO: Sort sessions by chain, actor, and permission
|
||||
|
||||
this.storage.write('sessions', JSON.stringify(orderedSessions))
|
||||
} else {
|
||||
this.storage.write('sessions', JSON.stringify([serialized]))
|
||||
@@ -440,6 +520,7 @@ export class SessionKit {
|
||||
|
||||
getSessionOptions(options?: LoginOptions) {
|
||||
return {
|
||||
abis: this.abis,
|
||||
allowModify: this.allowModify,
|
||||
appName: this.appName,
|
||||
expireSeconds: this.expireSeconds,
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
import {APIClient, FetchProvider, Name, PermissionLevel} from '@greymass/eosio'
|
||||
import {SigningRequestEncodingOptions} from 'eosio-signing-request'
|
||||
import {APIClient, FetchProvider, NameType, PermissionLevel} from '@wharfkit/antelope'
|
||||
import type {ChainDefinition, Fetch} from '@wharfkit/common'
|
||||
import {SigningRequestEncodingOptions} from '@wharfkit/signing-request'
|
||||
import zlib from 'pako'
|
||||
|
||||
import {ChainDefinition, Fetch} from './types'
|
||||
import {UserInterface} from './ui'
|
||||
import {WalletPluginConfig, WalletPluginMetadata} from './wallet'
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface LoginHooks {
|
||||
* Options for creating a new context for a [[Kit.login]] call.
|
||||
*/
|
||||
export interface LoginContextOptions {
|
||||
appName?: Name
|
||||
appName?: NameType
|
||||
// client: APIClient
|
||||
chain?: ChainDefinition
|
||||
chains?: ChainDefinition[]
|
||||
@@ -52,7 +52,7 @@ export interface UserInterfaceWalletPlugin {
|
||||
* provide a way for plugins to add hooks into the process.
|
||||
*/
|
||||
export class LoginContext {
|
||||
appName: Name | undefined
|
||||
appName?: string
|
||||
// client: APIClient
|
||||
chain?: ChainDefinition
|
||||
chains: ChainDefinition[] = []
|
||||
@@ -71,7 +71,7 @@ export class LoginContext {
|
||||
}
|
||||
walletPlugins: UserInterfaceWalletPlugin[] = []
|
||||
constructor(options: LoginContextOptions) {
|
||||
this.appName = options.appName
|
||||
this.appName = String(options.appName)
|
||||
// this.client = options.client
|
||||
if (options.chains) {
|
||||
this.chains = options.chains
|
||||
|
||||
+60
-38
@@ -12,21 +12,23 @@ import {
|
||||
SignedTransaction,
|
||||
Transaction,
|
||||
TransactionType,
|
||||
} from '@greymass/eosio'
|
||||
} from '@wharfkit/antelope'
|
||||
import {ChainDefinition} from '@wharfkit/common'
|
||||
import type {ChainDefinitionType, Fetch, LocaleDefinitions} from '@wharfkit/common'
|
||||
import {
|
||||
AbiProvider,
|
||||
ChainId,
|
||||
RequestDataV2,
|
||||
RequestDataV3,
|
||||
RequestSignature,
|
||||
ResolvedSigningRequest,
|
||||
SigningRequest,
|
||||
} from 'eosio-signing-request'
|
||||
} from '@wharfkit/signing-request'
|
||||
|
||||
import {ABICache} from './abi'
|
||||
import {ABICache, ABICacheInterface} from '@wharfkit/abicache'
|
||||
import {
|
||||
AbstractTransactPlugin,
|
||||
BaseTransactPlugin,
|
||||
TransactABIDef,
|
||||
TransactArgs,
|
||||
TransactContext,
|
||||
TransactOptions,
|
||||
@@ -36,7 +38,6 @@ import {
|
||||
TransactRevisions,
|
||||
} from './transact'
|
||||
import {SessionStorage} from './storage'
|
||||
import {ChainDefinition, ChainDefinitionType, Fetch, LocaleDefinitions} from './types'
|
||||
import {getFetch} from './utils'
|
||||
import {SerializedWalletPlugin, WalletPlugin, WalletPluginSignResponse} from './wallet'
|
||||
import {UserInterface} from './ui'
|
||||
@@ -56,7 +57,8 @@ export interface SessionArgs {
|
||||
* Options for creating a new [[Session]].
|
||||
*/
|
||||
export interface SessionOptions {
|
||||
abiProvider?: AbiProvider
|
||||
abis?: TransactABIDef[]
|
||||
abiCache?: ABICacheInterface
|
||||
allowModify?: boolean
|
||||
appName?: NameType
|
||||
broadcast?: boolean
|
||||
@@ -71,6 +73,7 @@ export interface SessionOptions {
|
||||
export interface SerializedSession {
|
||||
actor: NameType
|
||||
chain: Checksum256Type
|
||||
default?: boolean
|
||||
permission: NameType
|
||||
walletPlugin: SerializedWalletPlugin
|
||||
}
|
||||
@@ -79,8 +82,9 @@ export interface SerializedSession {
|
||||
* A representation of a session to interact with a specific blockchain account.
|
||||
*/
|
||||
export class Session {
|
||||
readonly appName: Name | undefined
|
||||
readonly abiProvider: AbiProvider
|
||||
readonly appName?: string
|
||||
readonly abis: TransactABIDef[] = []
|
||||
readonly abiCache: ABICacheInterface
|
||||
readonly allowModify: boolean = true
|
||||
readonly broadcast: boolean = true
|
||||
readonly chain: ChainDefinition
|
||||
@@ -118,7 +122,10 @@ export class Session {
|
||||
|
||||
// Handle all the optional values provided
|
||||
if (options.appName) {
|
||||
this.appName = Name.from(options.appName)
|
||||
this.appName = String(options.appName)
|
||||
}
|
||||
if (options.abis) {
|
||||
this.abis = [...options.abis]
|
||||
}
|
||||
if (options.allowModify !== undefined) {
|
||||
this.allowModify = options.allowModify
|
||||
@@ -145,10 +152,10 @@ export class Session {
|
||||
if (options.transactPluginsOptions) {
|
||||
this.transactPluginsOptions = options.transactPluginsOptions
|
||||
}
|
||||
if (options.abiProvider) {
|
||||
this.abiProvider = options.abiProvider
|
||||
if (options.abiCache) {
|
||||
this.abiCache = options.abiCache
|
||||
} else {
|
||||
this.abiProvider = new ABICache(this.client)
|
||||
this.abiCache = new ABICache(this.client)
|
||||
}
|
||||
if (options.ui) {
|
||||
this.ui = options.ui
|
||||
@@ -210,9 +217,9 @@ export class Session {
|
||||
}
|
||||
|
||||
/**
|
||||
* Lifted from @greymass/eosio-signing-request.
|
||||
* Lifted from @wharfkit/antelope-signing-request.
|
||||
*
|
||||
* Copy of: https://github.com/greymass/eosio-signing-request/blob/6fc84b2355577d6461676bff417c76e4f6f2f5c3/src/signing-request.ts#L305
|
||||
* Copy of: https://github.com/greymass/@wharfkit/signing-request/blob/6fc84b2355577d6461676bff417c76e4f6f2f5c3/src/signing-request.ts#L305
|
||||
*
|
||||
* TODO: Remove. This will no longer be needed once the `clone` functionality in ESR is updated
|
||||
*/
|
||||
@@ -224,15 +231,15 @@ export class Session {
|
||||
/**
|
||||
* Create a clone of the given SigningRequest
|
||||
*
|
||||
* Overrides: https://github.com/greymass/eosio-signing-request/blob/6fc84b2355577d6461676bff417c76e4f6f2f5c3/src/signing-request.ts#L1112
|
||||
* Overrides: https://github.com/greymass/@wharfkit/signing-request/blob/6fc84b2355577d6461676bff417c76e4f6f2f5c3/src/signing-request.ts#L1112
|
||||
*
|
||||
* @param {SigningRequest} request The SigningRequest to clone
|
||||
* @param {AbiProvider} abiProvider The AbiProvider to use for the clone
|
||||
* @returns Returns a cloned SigningRequest with updated abiProvider and zlib
|
||||
* @param {ABICacheInterface} abiCache The ABICacheInterface to use for the clone
|
||||
* @returns Returns a cloned SigningRequest with updated abiCache and zlib
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
cloneRequest(request: SigningRequest, abiProvider: AbiProvider): SigningRequest {
|
||||
// Lifted from @greymass/eosio-signing-request method `clone()`
|
||||
cloneRequest(request: SigningRequest, abiCache: ABICacheInterface): SigningRequest {
|
||||
// Lifted from @wharfkit/antelope-signing-request method `clone()`
|
||||
// This was done to modify the zlib and abiProvider
|
||||
// TODO: Modify ESR library to expose this `clone()` functionality
|
||||
// TODO: This if statement should potentially just be:
|
||||
@@ -243,24 +250,24 @@ export class Session {
|
||||
}
|
||||
const RequestData = this.storageType(request.version)
|
||||
const data = RequestData.from(JSON.parse(JSON.stringify(request.data)))
|
||||
return new SigningRequest(request.version, data, zlib, abiProvider, signature)
|
||||
return new SigningRequest(request.version, data, zlib, abiCache, signature)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert any provided form of TransactArgs to a SigningRequest
|
||||
*
|
||||
* @param {TransactArgs} args
|
||||
* @param {AbiProvider} abiProvider
|
||||
* @param {ABICacheInterface} abiCache
|
||||
* @returns Returns a SigningRequest
|
||||
*/
|
||||
async createRequest(args: TransactArgs, abiProvider: AbiProvider): Promise<SigningRequest> {
|
||||
async createRequest(args: TransactArgs, abiCache: ABICacheInterface): Promise<SigningRequest> {
|
||||
let request: SigningRequest
|
||||
const options = {
|
||||
abiProvider,
|
||||
abiProvider: abiCache,
|
||||
zlib,
|
||||
}
|
||||
if (args.request && args.request instanceof SigningRequest) {
|
||||
request = this.cloneRequest(args.request, abiProvider)
|
||||
request = this.cloneRequest(args.request, abiCache)
|
||||
} else if (args.request) {
|
||||
request = SigningRequest.from(args.request, options)
|
||||
} else {
|
||||
@@ -283,15 +290,15 @@ export class Session {
|
||||
*
|
||||
* @param {SigningRequest} previous
|
||||
* @param {SigningRequest} modified
|
||||
* @param abiProvider
|
||||
* @param abiCache
|
||||
* @returns
|
||||
*/
|
||||
async updateRequest(
|
||||
previous: SigningRequest,
|
||||
modified: SigningRequest,
|
||||
abiProvider: AbiProvider
|
||||
abiCache: ABICacheInterface
|
||||
): Promise<SigningRequest> {
|
||||
const updatedRequest: SigningRequest = this.cloneRequest(modified, abiProvider)
|
||||
const updatedRequest: SigningRequest = this.cloneRequest(modified, abiCache)
|
||||
const info = updatedRequest.getRawInfo()
|
||||
// Take all the metadata from the previous and set it on the modified request.
|
||||
// This will preserve the metadata as it is modified by various plugins.
|
||||
@@ -336,7 +343,21 @@ export class Session {
|
||||
: this.broadcast
|
||||
|
||||
// The abi provider to use for this transaction, falling back to the session instance
|
||||
const abiProvider = options?.abiProvider || this.abiProvider
|
||||
const abiCache = options?.abiCache || this.abiCache
|
||||
|
||||
// Collect all the ABIs that have been passed in manually
|
||||
const abiDefs: TransactABIDef[] = [...this.abis]
|
||||
if (options?.abis) {
|
||||
// If we have ABIs in the options, add them.
|
||||
abiDefs.push(...options.abis)
|
||||
}
|
||||
|
||||
// If an array of ABIs are provided, set them on the abiCache
|
||||
if (abiCache['setAbi']) {
|
||||
abiDefs.forEach((def: TransactABIDef) => abiCache['setAbi'](def.account, def.abi))
|
||||
} else {
|
||||
throw new Error('Custom `abiCache` does not support `setAbi` method.')
|
||||
}
|
||||
|
||||
// The TransactPlugins to use for this transaction, falling back to the session instance
|
||||
const transactPlugins = options?.transactPlugins || this.transactPlugins
|
||||
@@ -351,11 +372,11 @@ export class Session {
|
||||
|
||||
// The context object for this transaction
|
||||
const context = new TransactContext({
|
||||
abiProvider,
|
||||
abiCache,
|
||||
appName: this.appName,
|
||||
chain: this.chain,
|
||||
client: this.client,
|
||||
createRequest: (args: TransactArgs) => this.createRequest(args, abiProvider),
|
||||
createRequest: (args: TransactArgs) => this.createRequest(args, abiCache),
|
||||
fetch: this.fetch,
|
||||
permissionLevel: this.permissionLevel,
|
||||
storage: this.storage,
|
||||
@@ -376,7 +397,7 @@ export class Session {
|
||||
}
|
||||
|
||||
// Process incoming TransactArgs and convert to a SigningRequest
|
||||
let request: SigningRequest = await this.createRequest(args, abiProvider)
|
||||
let request: SigningRequest = await this.createRequest(args, abiCache)
|
||||
|
||||
// Create TransactResult to eventually respond to this call with
|
||||
const result: TransactResult = {
|
||||
@@ -400,7 +421,7 @@ export class Session {
|
||||
|
||||
// If modification is allowed, change the current request.
|
||||
if (allowModify) {
|
||||
request = await this.updateRequest(request, response.request, abiProvider)
|
||||
request = await this.updateRequest(request, response.request, abiCache)
|
||||
}
|
||||
|
||||
if (response.signatures) {
|
||||
@@ -429,10 +450,6 @@ export class Session {
|
||||
context
|
||||
)
|
||||
|
||||
if (context.ui) {
|
||||
await context.ui.onSignComplete()
|
||||
}
|
||||
|
||||
// Merge signatures in to the TransactResult
|
||||
result.signatures.push(...walletResponse.signatures)
|
||||
|
||||
@@ -456,6 +473,11 @@ export class Session {
|
||||
// Run the `afterSign` hooks that were registered by the TransactPlugins
|
||||
for (const hook of context.hooks.afterSign) await hook(result, context)
|
||||
|
||||
// Notify the UI that the signing operations are complete
|
||||
if (context.ui) {
|
||||
await context.ui.onSignComplete()
|
||||
}
|
||||
|
||||
if (willBroadcast) {
|
||||
if (context.ui) {
|
||||
// Notify the UI that broadcast logic will be run against the transaction
|
||||
@@ -519,10 +541,10 @@ export class Session {
|
||||
async signTransaction(transaction: TransactionType): Promise<Signature[]> {
|
||||
// Create a TransactContext for the WalletPlugin to use
|
||||
const context = new TransactContext({
|
||||
abiProvider: this.abiProvider,
|
||||
abiCache: this.abiCache,
|
||||
chain: this.chain,
|
||||
client: this.client,
|
||||
createRequest: (args: TransactArgs) => this.createRequest(args, this.abiProvider),
|
||||
createRequest: (args: TransactArgs) => this.createRequest(args, this.abiCache),
|
||||
fetch: this.fetch,
|
||||
permissionLevel: this.permissionLevel,
|
||||
})
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ export interface SessionStorage {
|
||||
}
|
||||
|
||||
export class BrowserLocalStorage implements SessionStorage {
|
||||
constructor(readonly keyPrefix: string) {}
|
||||
constructor(readonly keyPrefix: string = '') {}
|
||||
async write(key: string, data: string): Promise<void> {
|
||||
localStorage.setItem(this.storageKey(key), data)
|
||||
}
|
||||
|
||||
+40
-20
@@ -1,25 +1,27 @@
|
||||
import zlib from 'pako'
|
||||
import {
|
||||
ABIDef,
|
||||
AnyAction,
|
||||
AnyTransaction,
|
||||
API,
|
||||
APIClient,
|
||||
Checksum256Type,
|
||||
Name,
|
||||
NameType,
|
||||
PermissionLevel,
|
||||
Serializer,
|
||||
Signature,
|
||||
} from '@greymass/eosio'
|
||||
} from '@wharfkit/antelope'
|
||||
import {ABICacheInterface} from '@wharfkit/abicache'
|
||||
import type {ChainDefinition, Fetch, LocaleDefinitions} from '@wharfkit/common'
|
||||
import {
|
||||
AbiProvider,
|
||||
ResolvedSigningRequest,
|
||||
ResolvedTransaction,
|
||||
SigningRequest,
|
||||
SigningRequestEncodingOptions,
|
||||
} from 'eosio-signing-request'
|
||||
} from '@wharfkit/signing-request'
|
||||
|
||||
import {SessionStorage} from './storage'
|
||||
import {ChainDefinition, Fetch, LocaleDefinitions} from './types'
|
||||
import {UserInterface} from './ui'
|
||||
|
||||
export type TransactPluginsOptions = Record<string, unknown>
|
||||
@@ -57,8 +59,8 @@ export type TransactHookResponseType = TransactHookResponse | void
|
||||
* Options for creating a new context for a [[Session.transact]] call.
|
||||
*/
|
||||
export interface TransactContextOptions {
|
||||
abiProvider: AbiProvider
|
||||
appName?: Name
|
||||
abiCache: ABICacheInterface
|
||||
appName?: NameType
|
||||
chain: ChainDefinition
|
||||
client: APIClient
|
||||
createRequest: (args: TransactArgs) => Promise<SigningRequest>
|
||||
@@ -77,8 +79,8 @@ export interface TransactContextOptions {
|
||||
* provide a way for plugins to add hooks into the process.
|
||||
*/
|
||||
export class TransactContext {
|
||||
readonly abiProvider: AbiProvider
|
||||
readonly appName: Name | undefined
|
||||
readonly abiCache: ABICacheInterface
|
||||
readonly appName?: string
|
||||
readonly chain: ChainDefinition
|
||||
readonly client: APIClient
|
||||
readonly createRequest: (args: TransactArgs) => Promise<SigningRequest>
|
||||
@@ -95,8 +97,8 @@ export class TransactContext {
|
||||
readonly ui?: UserInterface
|
||||
|
||||
constructor(options: TransactContextOptions) {
|
||||
this.abiProvider = options.abiProvider
|
||||
this.appName = options.appName
|
||||
this.abiCache = options.abiCache
|
||||
this.appName = String(options.appName)
|
||||
this.chain = options.chain
|
||||
this.client = options.client
|
||||
this.createRequest = options.createRequest
|
||||
@@ -122,7 +124,7 @@ export class TransactContext {
|
||||
|
||||
get esrOptions(): SigningRequestEncodingOptions {
|
||||
return {
|
||||
abiProvider: this.abiProvider,
|
||||
abiProvider: this.abiCache,
|
||||
zlib,
|
||||
}
|
||||
}
|
||||
@@ -153,17 +155,26 @@ export class TransactContext {
|
||||
|
||||
async resolve(request: SigningRequest, expireSeconds = 120): Promise<ResolvedSigningRequest> {
|
||||
// Build the transaction header
|
||||
const info = await this.getInfo()
|
||||
const header = info.getTransactionHeader(expireSeconds)
|
||||
let resolveArgs = {
|
||||
chainId: this.chain.id,
|
||||
}
|
||||
|
||||
// Check if this request requires tapos generation
|
||||
if (request.requiresTapos()) {
|
||||
const info = await this.getInfo()
|
||||
const header = info.getTransactionHeader(expireSeconds)
|
||||
// override resolve args to include tapos headers
|
||||
resolveArgs = {
|
||||
...resolveArgs,
|
||||
...header,
|
||||
}
|
||||
}
|
||||
|
||||
// Load ABIs required to resolve this request
|
||||
const abis = await request.fetchAbis(this.abiProvider)
|
||||
const abis = await request.fetchAbis(this.abiCache)
|
||||
|
||||
// Resolve the request and return
|
||||
return request.resolve(abis, this.permissionLevel, {
|
||||
...header,
|
||||
chainId: this.chain.id,
|
||||
})
|
||||
return request.resolve(abis, this.permissionLevel, resolveArgs)
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -186,9 +197,13 @@ export interface TransactArgs {
|
||||
*/
|
||||
export interface TransactOptions {
|
||||
/**
|
||||
* An optional AbiProvider to control how ABIs are loaded.
|
||||
* An array of ABIs to use when resolving the transaction.
|
||||
*/
|
||||
abiProvider?: AbiProvider
|
||||
abis?: TransactABIDef[]
|
||||
/**
|
||||
* An optional ABICacheInterface to control how ABIs are loaded.
|
||||
*/
|
||||
abiCache?: ABICacheInterface
|
||||
/**
|
||||
* Whether to allow the signer to make modifications to the request
|
||||
* (e.g. applying a cosigner action to pay for resources).
|
||||
@@ -223,6 +238,11 @@ export interface TransactOptions {
|
||||
validatePluginSignatures?: boolean
|
||||
}
|
||||
|
||||
export interface TransactABIDef {
|
||||
account: NameType
|
||||
abi: ABIDef
|
||||
}
|
||||
|
||||
export interface TransactRevision {
|
||||
/**
|
||||
* Whether or not the context allowed any modification to take effect.
|
||||
|
||||
-222
@@ -1,222 +0,0 @@
|
||||
import {Checksum256, Checksum256Type, Struct} from '@greymass/eosio'
|
||||
|
||||
export type Fetch = (input: any, init?: any) => Promise<any>
|
||||
|
||||
/**
|
||||
* A list of chain IDs and their names for display purposes.
|
||||
*/
|
||||
export const chainNames: Map<Checksum256Type, string> = new Map([
|
||||
['aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', 'EOS'],
|
||||
['21dcae42c0182200e93f954a074011f9048a7624c6fe81d3c9541a614a88bd1c', 'FIO'],
|
||||
['b20901380af44ef59c5918439a1f9a41d83669020319a80574b804a5f95cbd7e', 'FIO (Testnet)'],
|
||||
['2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840', 'Jungle 3 (Testnet)'],
|
||||
['73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d', 'Jungle 4 (Testnet)'],
|
||||
['5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191', 'Kylin (Testnet)'],
|
||||
['38b1d7815474d0c60683ecbea321d723e83f5da6ae5f1c1f9fecc69d9ba96465', 'Libre'],
|
||||
['b64646740308df2ee06c6b72f34c0f7fa066d940e831f752db2006fcc2b78dee', 'Libre (Testnet)'],
|
||||
['384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e0', 'Proton'],
|
||||
['71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd', 'Proton (Testnet)'],
|
||||
['4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11', 'Telos'],
|
||||
['1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f', 'Telos (Testnet)'],
|
||||
['8fc6dce7942189f842170de953932b1f66693ad3788f766e777b6f9d22335c02', 'UX'],
|
||||
['1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4', 'WAX'],
|
||||
['f16b1833c747c43682f4386fca9cbb327929334a762755ebec17f6f23c9b8a12', 'WAX (Testnet)'],
|
||||
])
|
||||
|
||||
export type LogoType = Logo | {dark: string; light: string} | string
|
||||
|
||||
@Struct.type('logo')
|
||||
export class Logo extends Struct {
|
||||
@Struct.field('string') declare dark: string
|
||||
@Struct.field('string') declare light: string
|
||||
|
||||
static from(data: LogoType): Logo {
|
||||
if (typeof data === 'string') {
|
||||
return new Logo({light: data, dark: data})
|
||||
}
|
||||
return super.from(data) as Logo
|
||||
}
|
||||
|
||||
getVariant(variant: 'dark' | 'light'): string | undefined {
|
||||
return this[variant]
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.light
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of known chain IDs and their logos.
|
||||
*/
|
||||
export const chainLogos: Map<Checksum256Type, LogoType> = new Map([
|
||||
[
|
||||
'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
|
||||
'https://assets.wharfkit.com/chain/eos.png',
|
||||
],
|
||||
[
|
||||
'21dcae42c0182200e93f954a074011f9048a7624c6fe81d3c9541a614a88bd1c',
|
||||
'https://assets.wharfkit.com/chain/fio.png',
|
||||
],
|
||||
[
|
||||
'b20901380af44ef59c5918439a1f9a41d83669020319a80574b804a5f95cbd7e',
|
||||
'https://assets.wharfkit.com/chain/fio.png',
|
||||
],
|
||||
[
|
||||
'2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840',
|
||||
'https://assets.wharfkit.com/chain/jungle.png',
|
||||
],
|
||||
[
|
||||
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
'https://assets.wharfkit.com/chain/jungle.png',
|
||||
],
|
||||
[
|
||||
'38b1d7815474d0c60683ecbea321d723e83f5da6ae5f1c1f9fecc69d9ba96465',
|
||||
'https://assets.wharfkit.com/chain/libre.png',
|
||||
],
|
||||
[
|
||||
'b64646740308df2ee06c6b72f34c0f7fa066d940e831f752db2006fcc2b78dee',
|
||||
'https://assets.wharfkit.com/chain/libre.png',
|
||||
],
|
||||
[
|
||||
'384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e0',
|
||||
'https://assets.wharfkit.com/chain/proton.png',
|
||||
],
|
||||
[
|
||||
'71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd',
|
||||
'https://assets.wharfkit.com/chain/proton.png',
|
||||
],
|
||||
[
|
||||
'4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
'https://assets.wharfkit.com/chain/telos.png',
|
||||
],
|
||||
[
|
||||
'1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f',
|
||||
'https://assets.wharfkit.com/chain/telos.png',
|
||||
],
|
||||
[
|
||||
'8fc6dce7942189f842170de953932b1f66693ad3788f766e777b6f9d22335c02',
|
||||
'https://assets.wharfkit.com/chain/ux.png',
|
||||
],
|
||||
[
|
||||
'1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4',
|
||||
'https://assets.wharfkit.com/chain/wax.png',
|
||||
],
|
||||
[
|
||||
'f16b1833c747c43682f4386fca9cbb327929334a762755ebec17f6f23c9b8a12',
|
||||
'https://assets.wharfkit.com/chain/wax.png',
|
||||
],
|
||||
])
|
||||
|
||||
@Struct.type('explorer_definition')
|
||||
export class ExplorerDefinition extends Struct {
|
||||
@Struct.field('string') declare prefix: string
|
||||
@Struct.field('string') declare suffix: string
|
||||
|
||||
public url(id: string) {
|
||||
return `${this.prefix}${id}${this.suffix}`
|
||||
}
|
||||
}
|
||||
|
||||
export type ExplorerDefinitionType =
|
||||
| ExplorerDefinition
|
||||
| {prefix: string; suffix: string; url: (id: string) => string}
|
||||
|
||||
/**
|
||||
* The information required to interact with a given chain.
|
||||
*/
|
||||
@Struct.type('chain_definition')
|
||||
export class ChainDefinition extends Struct {
|
||||
/**
|
||||
* The chain ID.
|
||||
*/
|
||||
@Struct.field('checksum256') declare id: Checksum256
|
||||
/**
|
||||
* The base URL of the chain's API endpoint (e.g. https://jungle4.greymass.com).
|
||||
*/
|
||||
@Struct.field('string') declare url: string
|
||||
/**
|
||||
* The absolute URL(s) to the chain's logo.
|
||||
*/
|
||||
@Struct.field(Logo, {optional: true}) declare logo?: LogoType
|
||||
/**
|
||||
* The explorer definition for the chain.
|
||||
*/
|
||||
@Struct.field(ExplorerDefinition, {optional: true}) declare explorer?: ExplorerDefinitionType
|
||||
|
||||
static from(data) {
|
||||
return super.from({
|
||||
...data,
|
||||
explorer: data.explorer ? ExplorerDefinition.from(data.explorer) : undefined,
|
||||
logo: data.logo ? Logo.from(data.logo) : undefined,
|
||||
}) as ChainDefinition
|
||||
}
|
||||
|
||||
get name() {
|
||||
const id = String(this.id)
|
||||
return chainNames.has(id) ? chainNames.get(id) : 'Unknown blockchain'
|
||||
}
|
||||
|
||||
public getLogo(): Logo | undefined {
|
||||
const id = String(this.id)
|
||||
if (this.logo) {
|
||||
return Logo.from(this.logo)
|
||||
}
|
||||
if (chainLogos.has(id)) {
|
||||
const logo = chainLogos.get(id)
|
||||
if (logo) {
|
||||
return Logo.from(logo)
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export type ChainDefinitionType =
|
||||
| ChainDefinition
|
||||
| {id: Checksum256Type; url: string; explorer?: ExplorerDefinitionType; logo?: LogoType}
|
||||
|
||||
export type LocaleDefinitions = Record<string, any>
|
||||
|
||||
/**
|
||||
* Cancelable promises
|
||||
*
|
||||
* https://stackoverflow.com/questions/46461801/possible-to-add-a-cancel-method-to-promise-in-typescript/46464377#46464377
|
||||
*/
|
||||
|
||||
export class Canceled extends Error {
|
||||
silent = false
|
||||
constructor(reason, silent = false) {
|
||||
super(reason)
|
||||
this.silent = silent
|
||||
Object.setPrototypeOf(this, Canceled.prototype)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Cancelable<T> extends Promise<T> {
|
||||
cancel(reason?: string, silent?: boolean): Cancelable<T>
|
||||
}
|
||||
|
||||
export function cancelable<T>(
|
||||
promise: Promise<T>,
|
||||
onCancel?: (canceled: Canceled) => void
|
||||
): Cancelable<T> {
|
||||
let cancel: ((reason: string, silent: boolean) => Cancelable<T>) | null = null
|
||||
const cancelable: Cancelable<T> = <Cancelable<T>>new Promise((resolve, reject) => {
|
||||
cancel = (reason = '', silent = false) => {
|
||||
try {
|
||||
if (onCancel) {
|
||||
onCancel(new Canceled(reason, silent))
|
||||
}
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
return cancelable
|
||||
}
|
||||
promise.then(resolve, reject)
|
||||
})
|
||||
if (cancel) {
|
||||
cancelable.cancel = cancel
|
||||
}
|
||||
return cancelable
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Checksum256Type, PermissionLevelType} from '@greymass/eosio'
|
||||
import {Checksum256Type, PermissionLevelType} from '@wharfkit/antelope'
|
||||
import type {Cancelable, LocaleDefinitions} from '@wharfkit/common'
|
||||
|
||||
import {LoginOptions} from './kit'
|
||||
import {LoginContext} from './login'
|
||||
import {Cancelable, LocaleDefinitions} from './types'
|
||||
|
||||
/**
|
||||
* The arguments for a [[UserInterface.prompt]] call.
|
||||
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
import {Action, AnyAction, FetchProviderOptions, Transaction} from '@greymass/eosio'
|
||||
import {SigningRequest} from 'eosio-signing-request'
|
||||
|
||||
import {Fetch} from './types'
|
||||
import {Action, AnyAction, FetchProviderOptions, Transaction} from '@wharfkit/antelope'
|
||||
import type {Fetch} from '@wharfkit/common'
|
||||
import {SigningRequest} from '@wharfkit/signing-request'
|
||||
|
||||
/**
|
||||
* Return an instance of fetch.
|
||||
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
import {Checksum256, Checksum256Type, PermissionLevel, Signature, Struct} from '@greymass/eosio'
|
||||
import {ResolvedSigningRequest} from 'eosio-signing-request'
|
||||
import {Checksum256, Checksum256Type, PermissionLevel, Signature, Struct} from '@wharfkit/antelope'
|
||||
import {Logo} from '@wharfkit/common'
|
||||
import type {LocaleDefinitions} from '@wharfkit/common'
|
||||
import {ResolvedSigningRequest} from '@wharfkit/signing-request'
|
||||
|
||||
import {LoginContext} from './login'
|
||||
import {TransactContext} from './transact'
|
||||
import {LocaleDefinitions, Logo} from './types'
|
||||
|
||||
/**
|
||||
* The static configuration of a [[WalletPlugin]].
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"request": {
|
||||
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": "{\"account_name\":\"\"}"
|
||||
}
|
||||
},
|
||||
"status": 500,
|
||||
"json": {
|
||||
"code": 500,
|
||||
"message": "Internal Service Error",
|
||||
"error": {
|
||||
"code": 0,
|
||||
"name": "exception",
|
||||
"what": "unspecified",
|
||||
"details": [
|
||||
{
|
||||
"message": "unknown key (eosio::chain::name): ",
|
||||
"file": "http_plugin.cpp",
|
||||
"line_number": 954,
|
||||
"method": "handle_exception"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"text": "{\"code\":500,\"message\":\"Internal Service Error\",\"error\":{\"code\":0,\"name\":\"exception\",\"what\":\"unspecified\",\"details\":[{\"message\":\"unknown key (eosio::chain::name): \",\"file\":\"http_plugin.cpp\",\"line_number\":954,\"method\":\"handle_exception\"}]}}"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"request": {
|
||||
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": "{\"account_name\":\"eosio.token\"}"
|
||||
}
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"account_name": "eosio.token",
|
||||
"code_hash": "33109b3dd5d354cab5a425c1d4c404c4db056717215f1a8b7ba036a6692811df",
|
||||
"abi_hash": "d84356074da34a976528321472d73ac919227b9b01d9de59d8ade6d96440455c",
|
||||
"abi": "DmVvc2lvOjphYmkvMS4yAAgHYWNjb3VudAABB2JhbGFuY2UFYXNzZXQFY2xvc2UAAgVvd25lcgRuYW1lBnN5bWJvbAZzeW1ib2wGY3JlYXRlAAIGaXNzdWVyBG5hbWUObWF4aW11bV9zdXBwbHkFYXNzZXQOY3VycmVuY3lfc3RhdHMAAwZzdXBwbHkFYXNzZXQKbWF4X3N1cHBseQVhc3NldAZpc3N1ZXIEbmFtZQVpc3N1ZQADAnRvBG5hbWUIcXVhbnRpdHkFYXNzZXQEbWVtbwZzdHJpbmcEb3BlbgADBW93bmVyBG5hbWUGc3ltYm9sBnN5bWJvbAlyYW1fcGF5ZXIEbmFtZQZyZXRpcmUAAghxdWFudGl0eQVhc3NldARtZW1vBnN0cmluZwh0cmFuc2ZlcgAEBGZyb20EbmFtZQJ0bwRuYW1lCHF1YW50aXR5BWFzc2V0BG1lbW8Gc3RyaW5nBgAAAAAAhWlEBWNsb3NlAAAAAACobNRFBmNyZWF0ZQAAAAAAAKUxdgVpc3N1ZQAAAAAAADBVpQRvcGVuAAAAAACo67K6BnJldGlyZQAAAABXLTzNzQh0cmFuc2ZlcgACAAAAOE9NETIDaTY0AAAHYWNjb3VudAAAAAAAkE3GA2k2NAAADmN1cnJlbmN5X3N0YXRzAAAAAA==="
|
||||
},
|
||||
"text": "{\"account_name\":\"eosio.token\",\"code_hash\":\"33109b3dd5d354cab5a425c1d4c404c4db056717215f1a8b7ba036a6692811df\",\"abi_hash\":\"d84356074da34a976528321472d73ac919227b9b01d9de59d8ade6d96440455c\",\"abi\":\"DmVvc2lvOjphYmkvMS4yAAgHYWNjb3VudAABB2JhbGFuY2UFYXNzZXQFY2xvc2UAAgVvd25lcgRuYW1lBnN5bWJvbAZzeW1ib2wGY3JlYXRlAAIGaXNzdWVyBG5hbWUObWF4aW11bV9zdXBwbHkFYXNzZXQOY3VycmVuY3lfc3RhdHMAAwZzdXBwbHkFYXNzZXQKbWF4X3N1cHBseQVhc3NldAZpc3N1ZXIEbmFtZQVpc3N1ZQADAnRvBG5hbWUIcXVhbnRpdHkFYXNzZXQEbWVtbwZzdHJpbmcEb3BlbgADBW93bmVyBG5hbWUGc3ltYm9sBnN5bWJvbAlyYW1fcGF5ZXIEbmFtZQZyZXRpcmUAAghxdWFudGl0eQVhc3NldARtZW1vBnN0cmluZwh0cmFuc2ZlcgAEBGZyb20EbmFtZQJ0bwRuYW1lCHF1YW50aXR5BWFzc2V0BG1lbW8Gc3RyaW5nBgAAAAAAhWlEBWNsb3NlAAAAAACobNRFBmNyZWF0ZQAAAAAAAKUxdgVpc3N1ZQAAAAAAADBVpQRvcGVuAAAAAACo67K6BnJldGlyZQAAAABXLTzNzQh0cmFuc2ZlcgACAAAAOE9NETIDaTY0AAAHYWNjb3VudAAAAAAAkE3GA2k2NAAADmN1cnJlbmN5X3N0YXRzAAAAAA===\"}"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"request": {
|
||||
"path": "https://jungle4.greymass.com/v1/resource_provider/request_transaction",
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": "{\"ref\":\"unittest\",\"request\":\"esr://gmNgZPITm5j8mV1jdVUvAxAwggiGVwahDZdNY2Jf-rgwBrhw3DxY6vsYLDFh4ymOho0T42LVek-B1AIA\",\"signer\":{\"actor\":\"wharfkit1125\",\"permission\":\"test\"}}"
|
||||
}
|
||||
},
|
||||
"status": 400,
|
||||
"json": {
|
||||
"code": 400,
|
||||
"message": "Unable to process and sample transaction",
|
||||
"data": {
|
||||
"request": "esr://gmNgZPITm5j8mV1jdVUvAxAwggiGVwahDZdNY2Jf-rgwBrhw3DxY6vsYLDFh4ymOho0T42LVek-B1AIA",
|
||||
"error": {
|
||||
"path": "/v1/chain/compute_transaction",
|
||||
"response": {
|
||||
"headers": {
|
||||
"access-control-allow-headers": "X-Requested-With,Accept,Content-Type,Origin",
|
||||
"access-control-allow-methods": "GET, POST, OPTIONS",
|
||||
"access-control-allow-origin": "*",
|
||||
"connection": "close",
|
||||
"content-length": "407",
|
||||
"content-type": "application/json",
|
||||
"date": "Wed, 26 Jul 2023 04:58:04 GMT",
|
||||
"server": "nginx/1.18.0 (Ubuntu)"
|
||||
},
|
||||
"status": 500,
|
||||
"json": {
|
||||
"code": 500,
|
||||
"message": "Internal Service Error",
|
||||
"error": {
|
||||
"code": 3040005,
|
||||
"name": "expired_tx_exception",
|
||||
"what": "Expired Transaction",
|
||||
"details": [
|
||||
{
|
||||
"message": "expired transaction 1775ff8bdd5247a27f2a12015bd78b8d0660f40dac10a10f6c288fdecd530649, expiration 2022-12-07T22:40:14.000, block time 2023-07-26T04:58:04.500",
|
||||
"file": "producer_plugin.cpp",
|
||||
"line_number": 658,
|
||||
"method": "process_incoming_transaction_async"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"text": "{\"code\":500,\"message\":\"Internal Service Error\",\"error\":{\"code\":3040005,\"name\":\"expired_tx_exception\",\"what\":\"Expired Transaction\",\"details\":[{\"message\":\"expired transaction 1775ff8bdd5247a27f2a12015bd78b8d0660f40dac10a10f6c288fdecd530649, expiration 2022-12-07T22:40:14.000, block time 2023-07-26T04:58:04.500\",\"file\":\"producer_plugin.cpp\",\"line_number\":658,\"method\":\"process_incoming_transaction_async\"}]}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"text": "{\"code\":400,\"message\":\"Unable to process and sample transaction\",\"data\":{\"request\":\"esr://gmNgZPITm5j8mV1jdVUvAxAwggiGVwahDZdNY2Jf-rgwBrhw3DxY6vsYLDFh4ymOho0T42LVek-B1AIA\",\"error\":{\"path\":\"/v1/chain/compute_transaction\",\"response\":{\"headers\":{\"access-control-allow-headers\":\"X-Requested-With,Accept,Content-Type,Origin\",\"access-control-allow-methods\":\"GET, POST, OPTIONS\",\"access-control-allow-origin\":\"*\",\"connection\":\"close\",\"content-length\":\"407\",\"content-type\":\"application/json\",\"date\":\"Wed, 26 Jul 2023 04:58:04 GMT\",\"server\":\"nginx/1.18.0 (Ubuntu)\"},\"status\":500,\"json\":{\"code\":500,\"message\":\"Internal Service Error\",\"error\":{\"code\":3040005,\"name\":\"expired_tx_exception\",\"what\":\"Expired Transaction\",\"details\":[{\"message\":\"expired transaction 1775ff8bdd5247a27f2a12015bd78b8d0660f40dac10a10f6c288fdecd530649, expiration 2022-12-07T22:40:14.000, block time 2023-07-26T04:58:04.500\",\"file\":\"producer_plugin.cpp\",\"line_number\":658,\"method\":\"process_incoming_transaction_async\"}]}},\"text\":\"{\\\"code\\\":500,\\\"message\\\":\\\"Internal Service Error\\\",\\\"error\\\":{\\\"code\\\":3040005,\\\"name\\\":\\\"expired_tx_exception\\\",\\\"what\\\":\\\"Expired Transaction\\\",\\\"details\\\":[{\\\"message\\\":\\\"expired transaction 1775ff8bdd5247a27f2a12015bd78b8d0660f40dac10a10f6c288fdecd530649, expiration 2022-12-07T22:40:14.000, block time 2023-07-26T04:58:04.500\\\",\\\"file\\\":\\\"producer_plugin.cpp\\\",\\\"line_number\\\":658,\\\"method\\\":\\\"process_incoming_transaction_async\\\"}]}}\"}}}}"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"request": {
|
||||
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": "{\"account_name\":\"eosio.evm\"}"
|
||||
}
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"account_name": "eosio.evm",
|
||||
"code_hash": "307f058ce08f344ed3fddbd2e641c66e269f8e363422d61de982ed8d0fecdab4",
|
||||
"abi_hash": "7d9dd264fe6b930ed0237860d3ab06be62d0fd923b5401fcaab6caec000f7fd7",
|
||||
"abi": "DmVvc2lvOjphYmkvMS4yABcHYWNjb3VudAAFAmlkBnVpbnQ2NAtldGhfYWRkcmVzcwVieXRlcwVub25jZQZ1aW50NjQHYmFsYW5jZQVieXRlcwdjb2RlX2lkB3VpbnQ2ND8MYWNjb3VudF9jb2RlAAQCaWQGdWludDY0CXJlZl9jb3VudAZ1aW50MzIEY29kZQVieXRlcwljb2RlX2hhc2gFYnl0ZXMJYWRkZWdyZXNzAAEIYWNjb3VudHMGbmFtZVtdFmFsbG93ZWRfZWdyZXNzX2FjY291bnQAAQdhY2NvdW50BG5hbWUHYmFsYW5jZQACBW93bmVyBG5hbWUHYmFsYW5jZRFiYWxhbmNlX3dpdGhfZHVzdBFiYWxhbmNlX3dpdGhfZHVzdAACB2JhbGFuY2UFYXNzZXQEZHVzdAZ1aW50NjQFY2xvc2UAAQVvd25lcgRuYW1lBmNvbmZpZwAHB3ZlcnNpb24JdmFydWludDMyB2NoYWluaWQGdWludDY0DGdlbmVzaXNfdGltZQ50aW1lX3BvaW50X3NlYxJpbmdyZXNzX2JyaWRnZV9mZWUFYXNzZXQJZ2FzX3ByaWNlBnVpbnQ2NAltaW5lcl9jdXQGdWludDMyBnN0YXR1cwZ1aW50MzIEZXhlYwACBWlucHV0CmV4ZWNfaW5wdXQIY2FsbGJhY2sOZXhlY19jYWxsYmFjaz8NZXhlY19jYWxsYmFjawACCGNvbnRyYWN0BG5hbWUGYWN0aW9uBG5hbWUKZXhlY19pbnB1dAAFB2NvbnRleHQGYnl0ZXM/BGZyb20GYnl0ZXM/AnRvBWJ5dGVzBGRhdGEFYnl0ZXMFdmFsdWUGYnl0ZXM/DmZlZV9wYXJhbWV0ZXJzAAMJZ2FzX3ByaWNlB3VpbnQ2ND8JbWluZXJfY3V0B3VpbnQzMj8SaW5ncmVzc19icmlkZ2VfZmVlBmFzc2V0PwZmcmVlemUAAQV2YWx1ZQRib29sAmdjAAEDbWF4BnVpbnQzMgdnY3N0b3JlAAICaWQGdWludDY0CnN0b3JhZ2VfaWQGdWludDY0BGluaXQAAgdjaGFpbmlkBnVpbnQ2NApmZWVfcGFyYW1zDmZlZV9wYXJhbWV0ZXJzCW5leHRub25jZQACBW93bmVyBG5hbWUKbmV4dF9ub25jZQZ1aW50NjQEb3BlbgABBW93bmVyBG5hbWUGcHVzaHR4AAIFbWluZXIEbmFtZQVybHB0eAVieXRlcwxyZW1vdmVlZ3Jlc3MAAQhhY2NvdW50cwZuYW1lW10Mc2V0ZmVlcGFyYW1zAAEKZmVlX3BhcmFtcw5mZWVfcGFyYW1ldGVycwdzdG9yYWdlAAMCaWQGdWludDY0A2tleQVieXRlcwV2YWx1ZQVieXRlcwh3aXRoZHJhdwADBW93bmVyBG5hbWUIcXVhbnRpdHkFYXNzZXQCdG8FbmFtZSQLAADAWF2mUjIJYWRkZWdyZXNzAAAAAAAAhWlEBWNsb3NlAAAAAAAAgFRXBGV4ZWMAAAAAAKiv1F0GZnJlZXplAAAAAAAAAABiAmdjAAAAAAAAkN10BGluaXQAAAAAAAAwVaUEb3BlbgAAAAAA9NywrgZwdXNodHgAgLG6TKlNpboMcmVtb3ZlZWdyZXNzAICluaYqtbLCDHNldGZlZXBhcmFtcwAAAADc3NSy4wh3aXRoZHJhdwAJAAAAIE9NETIDaTY0AAAHYWNjb3VudABUoihPTREyA2k2NAAADGFjY291bnRfY29kZQAAAFihaaI5A2k2NAAAB2JhbGFuY2UAAAAAMLcmRQNpNjQAAAZjb25maWcAQMYuYqwuUwNpNjQAABZhbGxvd2VkX2VncmVzc19hY2NvdW50AAAAQF2aMWIDaTY0AAAHZ2NzdG9yZQAAAAAAudV0A2k2NAAAEWJhbGFuY2Vfd2l0aF9kdXN0AABWaNKZu5oDaTY0AAAJbmV4dG5vbmNlAAAAQDFzacYDaTY0AAAHc3RvcmFnZQAAAAABAAAAAAAAAGIEYm9vbA==="
|
||||
},
|
||||
"text": "{\"account_name\":\"eosio.evm\",\"code_hash\":\"307f058ce08f344ed3fddbd2e641c66e269f8e363422d61de982ed8d0fecdab4\",\"abi_hash\":\"7d9dd264fe6b930ed0237860d3ab06be62d0fd923b5401fcaab6caec000f7fd7\",\"abi\":\"DmVvc2lvOjphYmkvMS4yABcHYWNjb3VudAAFAmlkBnVpbnQ2NAtldGhfYWRkcmVzcwVieXRlcwVub25jZQZ1aW50NjQHYmFsYW5jZQVieXRlcwdjb2RlX2lkB3VpbnQ2ND8MYWNjb3VudF9jb2RlAAQCaWQGdWludDY0CXJlZl9jb3VudAZ1aW50MzIEY29kZQVieXRlcwljb2RlX2hhc2gFYnl0ZXMJYWRkZWdyZXNzAAEIYWNjb3VudHMGbmFtZVtdFmFsbG93ZWRfZWdyZXNzX2FjY291bnQAAQdhY2NvdW50BG5hbWUHYmFsYW5jZQACBW93bmVyBG5hbWUHYmFsYW5jZRFiYWxhbmNlX3dpdGhfZHVzdBFiYWxhbmNlX3dpdGhfZHVzdAACB2JhbGFuY2UFYXNzZXQEZHVzdAZ1aW50NjQFY2xvc2UAAQVvd25lcgRuYW1lBmNvbmZpZwAHB3ZlcnNpb24JdmFydWludDMyB2NoYWluaWQGdWludDY0DGdlbmVzaXNfdGltZQ50aW1lX3BvaW50X3NlYxJpbmdyZXNzX2JyaWRnZV9mZWUFYXNzZXQJZ2FzX3ByaWNlBnVpbnQ2NAltaW5lcl9jdXQGdWludDMyBnN0YXR1cwZ1aW50MzIEZXhlYwACBWlucHV0CmV4ZWNfaW5wdXQIY2FsbGJhY2sOZXhlY19jYWxsYmFjaz8NZXhlY19jYWxsYmFjawACCGNvbnRyYWN0BG5hbWUGYWN0aW9uBG5hbWUKZXhlY19pbnB1dAAFB2NvbnRleHQGYnl0ZXM/BGZyb20GYnl0ZXM/AnRvBWJ5dGVzBGRhdGEFYnl0ZXMFdmFsdWUGYnl0ZXM/DmZlZV9wYXJhbWV0ZXJzAAMJZ2FzX3ByaWNlB3VpbnQ2ND8JbWluZXJfY3V0B3VpbnQzMj8SaW5ncmVzc19icmlkZ2VfZmVlBmFzc2V0PwZmcmVlemUAAQV2YWx1ZQRib29sAmdjAAEDbWF4BnVpbnQzMgdnY3N0b3JlAAICaWQGdWludDY0CnN0b3JhZ2VfaWQGdWludDY0BGluaXQAAgdjaGFpbmlkBnVpbnQ2NApmZWVfcGFyYW1zDmZlZV9wYXJhbWV0ZXJzCW5leHRub25jZQACBW93bmVyBG5hbWUKbmV4dF9ub25jZQZ1aW50NjQEb3BlbgABBW93bmVyBG5hbWUGcHVzaHR4AAIFbWluZXIEbmFtZQVybHB0eAVieXRlcwxyZW1vdmVlZ3Jlc3MAAQhhY2NvdW50cwZuYW1lW10Mc2V0ZmVlcGFyYW1zAAEKZmVlX3BhcmFtcw5mZWVfcGFyYW1ldGVycwdzdG9yYWdlAAMCaWQGdWludDY0A2tleQVieXRlcwV2YWx1ZQVieXRlcwh3aXRoZHJhdwADBW93bmVyBG5hbWUIcXVhbnRpdHkFYXNzZXQCdG8FbmFtZSQLAADAWF2mUjIJYWRkZWdyZXNzAAAAAAAAhWlEBWNsb3NlAAAAAAAAgFRXBGV4ZWMAAAAAAKiv1F0GZnJlZXplAAAAAAAAAABiAmdjAAAAAAAAkN10BGluaXQAAAAAAAAwVaUEb3BlbgAAAAAA9NywrgZwdXNodHgAgLG6TKlNpboMcmVtb3ZlZWdyZXNzAICluaYqtbLCDHNldGZlZXBhcmFtcwAAAADc3NSy4wh3aXRoZHJhdwAJAAAAIE9NETIDaTY0AAAHYWNjb3VudABUoihPTREyA2k2NAAADGFjY291bnRfY29kZQAAAFihaaI5A2k2NAAAB2JhbGFuY2UAAAAAMLcmRQNpNjQAAAZjb25maWcAQMYuYqwuUwNpNjQAABZhbGxvd2VkX2VncmVzc19hY2NvdW50AAAAQF2aMWIDaTY0AAAHZ2NzdG9yZQAAAAAAudV0A2k2NAAAEWJhbGFuY2Vfd2l0aF9kdXN0AABWaNKZu5oDaTY0AAAJbmV4dG5vbmNlAAAAQDFzacYDaTY0AAAHc3RvcmFnZQAAAAABAAAAAAAAAGIEYm9vbA===\"}"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"request": {
|
||||
"path": "https://jungle4.greymass.com/v1/chain/get_raw_abi",
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": "{\"account_name\":\"greymassnoop\"}"
|
||||
}
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"account_name": "greymassnoop",
|
||||
"code_hash": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"abi_hash": "1245e8954bce991492621cd66ffe556ef2c2925ee03071a3fba996c83040f867",
|
||||
"abi": "DmVvc2lvOjphYmkvMS4xAAEEbm9vcAAAAQAAAAAAUCmdBG5vb3AZVGhpcyBhY3Rpb24gZG9lcyBub3RoaW5nLgAAAAAA="
|
||||
},
|
||||
"text": "{\"account_name\":\"greymassnoop\",\"code_hash\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"abi_hash\":\"1245e8954bce991492621cd66ffe556ef2c2925ee03071a3fba996c83040f867\",\"abi\":\"DmVvc2lvOjphYmkvMS4xAAEEbm9vcAAAAQAAAAAAUCmdBG5vb3AZVGhpcyBhY3Rpb24gZG9lcyBub3RoaW5nLgAAAAAA=\"}"
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export default [
|
||||
entries: [
|
||||
{find: '$lib', replacement: path.join(__dirname, '..', 'lib/session.m.js')},
|
||||
{
|
||||
find: '$test/utils/mock-fetch',
|
||||
find: '@wharfkit/mock-data',
|
||||
replacement: './test/utils/browser-fetch.ts',
|
||||
},
|
||||
],
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {ABI, ABICache, Name} from '@wharfkit/session'
|
||||
import {makeClient} from '@wharfkit/mock-data'
|
||||
import {ABI, Name} from '@wharfkit/session'
|
||||
import {ABICache} from '@wharfkit/abicache'
|
||||
import {assert} from 'chai'
|
||||
|
||||
const client = makeClient()
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import {Checksum256, PermissionLevel, Transaction} from '@greymass/eosio'
|
||||
import {Checksum256, PermissionLevel, Transaction} from '@wharfkit/antelope'
|
||||
import zlib from 'pako'
|
||||
|
||||
import {SigningRequest} from '$lib'
|
||||
import {makeMockAction} from '$test/utils/mock-transfer'
|
||||
import {makeMockAction} from '@wharfkit/mock-data'
|
||||
|
||||
import {makeContext} from '$test/utils/mock-context'
|
||||
import {makeContext} from '@wharfkit/mock-data'
|
||||
|
||||
const context = makeContext()
|
||||
|
||||
suite('context', function () {
|
||||
suite('abiProvider', function () {
|
||||
suite('abiCache', function () {
|
||||
test('has default', function () {
|
||||
assert.isDefined(context.abiProvider)
|
||||
assert.isDefined(context.abiCache)
|
||||
})
|
||||
})
|
||||
suite('getters', function () {
|
||||
|
||||
+4
-8
@@ -1,19 +1,15 @@
|
||||
import {beforeSignHooks} from './plugins/hooks/beforeSign'
|
||||
import {afterSignHooks} from './plugins/hooks/afterSign'
|
||||
import {afterBroadcastHooks} from './plugins/hooks/afterBroadcast'
|
||||
import {beforeLoginHooks} from './plugins/hooks/beforeLogin'
|
||||
import {afterLoginHooks} from './plugins/hooks/afterLogin'
|
||||
|
||||
suite('hooks', function () {
|
||||
// Perform transact hook tests within ./tests/plugins/hooks
|
||||
suite('transactHooks', function () {
|
||||
beforeSignHooks()
|
||||
afterSignHooks()
|
||||
afterBroadcastHooks()
|
||||
// afterSignHooks()
|
||||
// afterBroadcastHooks()
|
||||
})
|
||||
// Perform login hook tests
|
||||
suite('loginHooks', function () {
|
||||
beforeLoginHooks()
|
||||
afterLoginHooks()
|
||||
// beforeLoginHooks()
|
||||
// afterLoginHooks()
|
||||
})
|
||||
})
|
||||
|
||||
+162
-60
@@ -1,10 +1,11 @@
|
||||
import {assert} from 'chai'
|
||||
import {Checksum256, PermissionLevel, TimePointSec} from '@greymass/eosio'
|
||||
import {Checksum256, PermissionLevel, TimePointSec} from '@wharfkit/antelope'
|
||||
import {WalletPluginPrivateKey} from '@wharfkit/wallet-plugin-privatekey'
|
||||
|
||||
import {
|
||||
BaseTransactPlugin,
|
||||
ChainDefinition,
|
||||
Chains,
|
||||
ExplorerDefinition,
|
||||
Logo,
|
||||
Session,
|
||||
@@ -12,18 +13,18 @@ import {
|
||||
UserInterfaceLoginResponse,
|
||||
} from '$lib'
|
||||
|
||||
import {makeWallet, MockWalletPluginConfigs} from '$test/utils/mock-wallet'
|
||||
import {MockTransactPlugin} from '$test/utils/mock-hook'
|
||||
import {makeMockAction} from '$test/utils/mock-transfer'
|
||||
import {makeWallet, MockWalletPluginConfigs} from '@wharfkit/mock-data'
|
||||
import {MockTransactPlugin} from '@wharfkit/mock-data'
|
||||
import {makeMockAction} from '@wharfkit/mock-data'
|
||||
import {
|
||||
mockChainDefinition,
|
||||
mockChainDefinitions,
|
||||
mockChainId,
|
||||
mockPermissionLevel,
|
||||
} from '$test/utils/mock-config'
|
||||
import {MockUserInterface} from '$test/utils/mock-userinterface'
|
||||
import {mockSessionKit, mockSessionKitOptions} from '$test/utils/mock-session'
|
||||
import {MockStorage} from '$test/utils/mock-storage'
|
||||
} from '@wharfkit/mock-data'
|
||||
import {MockUserInterface} from '@wharfkit/mock-data'
|
||||
import {mockSessionKit, mockSessionKitArgs, mockSessionKitOptions} from '@wharfkit/mock-data'
|
||||
import {MockStorage} from '@wharfkit/mock-data'
|
||||
|
||||
const action = makeMockAction()
|
||||
|
||||
@@ -34,7 +35,7 @@ const defaultLoginOptions = {
|
||||
|
||||
function assertSessionMatchesMockSession(session: Session) {
|
||||
assert.instanceOf(session, Session)
|
||||
assert.isTrue(session.appName?.equals(mockSessionKitOptions.appName))
|
||||
assert.equal(session.appName, mockSessionKitArgs.appName)
|
||||
assert.equal(session.allowModify, true)
|
||||
assert.equal(session.broadcast, true)
|
||||
assert.equal(session.expireSeconds, 120)
|
||||
@@ -45,14 +46,84 @@ function assertSessionMatchesMockSession(session: Session) {
|
||||
suite('kit', function () {
|
||||
let sessionKit
|
||||
setup(async function () {
|
||||
sessionKit = new SessionKit({...mockSessionKitOptions})
|
||||
sessionKit = new SessionKit(mockSessionKitArgs, mockSessionKitOptions)
|
||||
await sessionKit.logout()
|
||||
})
|
||||
suite('construct', function () {
|
||||
test('instance', function () {
|
||||
assert.instanceOf(sessionKit, SessionKit)
|
||||
})
|
||||
suite('args', function () {
|
||||
test('Chains definitions', async function () {
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
chains: [Chains.Jungle4, Chains.EOS],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
const result = await kit.login({chain: Chains.EOS.id})
|
||||
assert.isTrue(result.response.chain.equals(Chains.EOS.id))
|
||||
})
|
||||
})
|
||||
suite('options', function () {
|
||||
suite('abis', function () {
|
||||
test('passing for all sessions', async function () {
|
||||
const abi = {
|
||||
version: 'eosio::abi/1.2',
|
||||
types: [],
|
||||
structs: [
|
||||
{
|
||||
name: 'transfer',
|
||||
base: '',
|
||||
fields: [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'to',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
type: 'asset',
|
||||
},
|
||||
{
|
||||
name: 'memo',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
name: 'transfer',
|
||||
type: 'transfer',
|
||||
ricardian_contract: '',
|
||||
},
|
||||
],
|
||||
tables: [],
|
||||
ricardian_clauses: [],
|
||||
error_messages: [],
|
||||
abi_extensions: [],
|
||||
variants: [],
|
||||
action_results: [],
|
||||
}
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
abis: [
|
||||
{
|
||||
account: 'eosio.token',
|
||||
abi,
|
||||
},
|
||||
],
|
||||
})
|
||||
assert.lengthOf(sessionKit.abis, 1)
|
||||
const {session} = await sessionKit.login()
|
||||
assert.lengthOf(session.abis, 1)
|
||||
})
|
||||
})
|
||||
suite('expireSeconds', function () {
|
||||
test('default: 120', async function () {
|
||||
const {session} = await sessionKit.login(defaultLoginOptions)
|
||||
@@ -66,7 +137,7 @@ suite('kit', function () {
|
||||
)
|
||||
})
|
||||
test('override: 60', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
expireSeconds: 60,
|
||||
})
|
||||
@@ -89,7 +160,7 @@ suite('kit', function () {
|
||||
assert.instanceOf(sessionKit.transactPlugins[0], BaseTransactPlugin)
|
||||
})
|
||||
test('override', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
transactPlugins: [new MockTransactPlugin()],
|
||||
})
|
||||
@@ -175,16 +246,19 @@ suite('kit', function () {
|
||||
)
|
||||
})
|
||||
test('default logo', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
chains: [
|
||||
{
|
||||
id: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
url: 'https://telos.greymass.com',
|
||||
logo: 'https://assets.wharfkit.com/chain/telos.png',
|
||||
},
|
||||
],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
chains: [
|
||||
{
|
||||
id: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
url: 'https://telos.greymass.com',
|
||||
logo: 'https://assets.wharfkit.com/chain/telos.png',
|
||||
},
|
||||
],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
assert.instanceOf(sessionKit.chains[0], ChainDefinition)
|
||||
assert.instanceOf(sessionKit.chains[0].id, Checksum256)
|
||||
assert.instanceOf(sessionKit.chains[0].logo, Logo)
|
||||
@@ -195,21 +269,24 @@ suite('kit', function () {
|
||||
assert.isString(sessionKit.chains[0].name)
|
||||
})
|
||||
test('specify logo', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
chains: [
|
||||
{
|
||||
id: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
url: 'https://telos.greymass.com',
|
||||
logo: 'https://assets.wharfkit.com/chain/eos.png',
|
||||
explorer: {
|
||||
prefix: 'https://explorer.telos.net/transaction/',
|
||||
suffix: '',
|
||||
url: (id) => this.prefix + id + this.suffix,
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
chains: [
|
||||
{
|
||||
id: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
url: 'https://telos.greymass.com',
|
||||
logo: 'https://assets.wharfkit.com/chain/eos.png',
|
||||
explorer: {
|
||||
prefix: 'https://explorer.telos.net/transaction/',
|
||||
suffix: '',
|
||||
url: (id) => this.prefix + id + this.suffix,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
assert.instanceOf(sessionKit.chains[0], ChainDefinition)
|
||||
assert.instanceOf(sessionKit.chains[0].id, Checksum256)
|
||||
assert.instanceOf(sessionKit.chains[0].logo, Logo)
|
||||
@@ -287,18 +364,34 @@ suite('kit', function () {
|
||||
assertSessionMatchesMockSession(restored)
|
||||
})
|
||||
test('no session returns undefined', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
storage: new MockStorage(),
|
||||
})
|
||||
const restored = await sessionKit.restore()
|
||||
assert.isUndefined(restored)
|
||||
})
|
||||
test('throws if wallet not found', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
walletPlugins: [new MockWalletPluginConfigs()],
|
||||
test('can restore with just actor, permission, and chainId', async function () {
|
||||
const {session} = await sessionKit.login()
|
||||
const mockSerializedSession = session.serialize()
|
||||
const restored = await mockSessionKit.restore({
|
||||
actor: mockSerializedSession.actor,
|
||||
permission: mockSerializedSession.permission,
|
||||
chain: mockSerializedSession.chain,
|
||||
})
|
||||
if (!restored) {
|
||||
throw new Error('Failed to restore session')
|
||||
}
|
||||
assertSessionMatchesMockSession(restored)
|
||||
})
|
||||
test('throws if wallet not found', async function () {
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
walletPlugins: [new MockWalletPluginConfigs()],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
const {session} = await sessionKit.login()
|
||||
const mockSerializedSession = session.serialize()
|
||||
let error
|
||||
@@ -312,7 +405,7 @@ suite('kit', function () {
|
||||
})
|
||||
suite('restoreAll', function () {
|
||||
test('restores no sessions', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
storage: new MockStorage(),
|
||||
})
|
||||
@@ -323,7 +416,7 @@ suite('kit', function () {
|
||||
})
|
||||
test('restores all sessions', async function () {
|
||||
// New kit w/ empty storage
|
||||
const sessionKit = new SessionKit({
|
||||
const sessionKit = new SessionKit(mockSessionKitArgs, {
|
||||
...mockSessionKitOptions,
|
||||
storage: new MockStorage(),
|
||||
})
|
||||
@@ -359,30 +452,36 @@ suite('kit', function () {
|
||||
assert.instanceOf(session.ui, MockUserInterface)
|
||||
})
|
||||
test('override', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
ui: new MockUserInterface(),
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{...mockSessionKitArgs, ui: new MockUserInterface()},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
assert.instanceOf(sessionKit.ui, MockUserInterface)
|
||||
const {session} = await sessionKit.login(defaultLoginOptions)
|
||||
assert.instanceOf(session.ui, MockUserInterface)
|
||||
})
|
||||
suite('onSelectWallet', function () {
|
||||
test('if 1 walletPlugin, use it without UI selection', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
})
|
||||
assertSessionMatchesMockSession(session)
|
||||
})
|
||||
test('if >1 walletPlugin, force selection', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
walletPlugins: [makeWallet(), makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
walletPlugins: [makeWallet(), makeWallet()],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
})
|
||||
@@ -398,11 +497,14 @@ suite('kit', function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
const sessionKit = new SessionKit({
|
||||
...mockSessionKitOptions,
|
||||
ui: new FailingUI(),
|
||||
walletPlugins: [makeWallet(), makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
...mockSessionKitArgs,
|
||||
ui: new FailingUI(),
|
||||
walletPlugins: [makeWallet(), makeWallet()],
|
||||
},
|
||||
mockSessionKitOptions
|
||||
)
|
||||
let error
|
||||
try {
|
||||
await sessionKit.login()
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
export const afterBroadcastHooks = () => {
|
||||
suite('afterBroadcast', function () {
|
||||
test('TODO', async function () {})
|
||||
})
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
export const afterLoginHooks = () => {
|
||||
suite('afterLogin', function () {
|
||||
test('TODO', async function () {})
|
||||
})
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {makeContext} from '$test/utils/mock-context'
|
||||
|
||||
const client = makeClient()
|
||||
const context = makeContext()
|
||||
|
||||
export const afterSignHooks = () => {
|
||||
suite('afterSign', function () {
|
||||
test('TODO', async function () {})
|
||||
})
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
export const beforeLoginHooks = () => {
|
||||
suite('beforeLogin', function () {
|
||||
test('TODO', async function () {})
|
||||
})
|
||||
}
|
||||
@@ -2,13 +2,13 @@ import {assert} from 'chai'
|
||||
import zlib from 'pako'
|
||||
|
||||
import {SigningRequest} from '$lib'
|
||||
import {Name, Transaction} from '@greymass/eosio'
|
||||
import {Name, Transaction} from '@wharfkit/antelope'
|
||||
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {makeContext} from '$test/utils/mock-context'
|
||||
import {mockTransactResourceProviderPresignHook} from '$test/utils/mock-hook'
|
||||
import {makeMockAction, makeMockTransaction} from '$test/utils/mock-transfer'
|
||||
import {mockAccountName} from '$test/utils/mock-config'
|
||||
import {makeClient} from '@wharfkit/mock-data'
|
||||
import {makeContext} from '@wharfkit/mock-data'
|
||||
import {mockTransactResourceProviderPresignHook} from '@wharfkit/mock-data'
|
||||
import {makeMockAction, makeMockTransaction} from '@wharfkit/mock-data'
|
||||
import {mockAccountName} from '@wharfkit/mock-data'
|
||||
|
||||
const client = makeClient()
|
||||
const context = makeContext()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import {Action, Asset, AssetType, Name, Signature, Struct} from '@greymass/eosio'
|
||||
import {Action, Asset, AssetType, Name, Signature, Struct} from '@wharfkit/antelope'
|
||||
|
||||
import {
|
||||
AbstractTransactPlugin,
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
TransactHookTypes,
|
||||
} from '$lib'
|
||||
|
||||
import {mockChainId, mockUrl} from '$test/utils/mock-config'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {makeWallet} from '$test/utils/mock-wallet'
|
||||
import {mockChainId, mockUrl} from '@wharfkit/mock-data'
|
||||
import {mockFetch} from '@wharfkit/mock-data'
|
||||
import {makeWallet} from '@wharfkit/mock-data'
|
||||
|
||||
const wallet = makeWallet()
|
||||
|
||||
|
||||
+128
-56
@@ -1,18 +1,18 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import SessionKit, {BaseTransactPlugin, ChainDefinition, Session, SessionOptions} from '$lib'
|
||||
import {ABIDef, Name, PermissionLevel, Signature, TimePointSec} from '@greymass/eosio'
|
||||
import {ABI, ABIDef, Name, PermissionLevel, Signature, TimePointSec} from '@wharfkit/antelope'
|
||||
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {MockTransactPlugin, MockTransactResourceProviderPlugin} from '$test/utils/mock-hook'
|
||||
import {mockFetch} from '@wharfkit/mock-data'
|
||||
import {MockTransactPlugin, MockTransactResourceProviderPlugin} from '@wharfkit/mock-data'
|
||||
import {nodejsUsage} from './use-cases/general/nodejs'
|
||||
import {makeMockAction} from '$test/utils/mock-transfer'
|
||||
import {makeWallet} from '$test/utils/mock-wallet'
|
||||
import {mockPermissionLevel} from '$test/utils/mock-config'
|
||||
import {MockUserInterface} from '$test/utils/mock-userinterface'
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {mockSessionArgs} from '$test/utils/mock-session'
|
||||
import {MockStorage} from '$test/utils/mock-storage'
|
||||
import {makeMockAction} from '@wharfkit/mock-data'
|
||||
import {makeWallet} from '@wharfkit/mock-data'
|
||||
import {mockPermissionLevel} from '@wharfkit/mock-data'
|
||||
import {MockUserInterface} from '@wharfkit/mock-data'
|
||||
import {makeClient} from '@wharfkit/mock-data'
|
||||
import {mockSessionArgs} from '@wharfkit/mock-data'
|
||||
import {MockStorage} from '@wharfkit/mock-data'
|
||||
import {WalletPluginPrivateKey} from '@wharfkit/wallet-plugin-privatekey'
|
||||
|
||||
const wallet = makeWallet()
|
||||
@@ -39,19 +39,79 @@ suite('session', function () {
|
||||
assert.instanceOf(session, Session)
|
||||
})
|
||||
suite('options', function () {
|
||||
suite('abiProvider', function () {
|
||||
suite('abiCache', function () {
|
||||
test('specify provider', function () {
|
||||
const client = makeClient()
|
||||
const abiProvider = {
|
||||
const abiCache = {
|
||||
foo: 'bar',
|
||||
cache: new Map(),
|
||||
pending: new Map(),
|
||||
getAbi: async (account) =>
|
||||
(await client.v1.chain.get_abi(account)).abi as ABIDef,
|
||||
ABI.from((await client.v1.chain.get_abi(account)).abi as ABIDef),
|
||||
setAbi: () => {
|
||||
// NYI
|
||||
},
|
||||
}
|
||||
const testSession = new Session(mockSessionArgs, {
|
||||
...mockSessionOptions,
|
||||
abiProvider,
|
||||
abiCache,
|
||||
})
|
||||
assert.equal(testSession.abiProvider['foo'], 'bar')
|
||||
assert.equal(testSession.abiCache['foo'], 'bar')
|
||||
})
|
||||
})
|
||||
suite('abis', function () {
|
||||
test('passing for entire session', async function () {
|
||||
const abi = {
|
||||
version: 'eosio::abi/1.2',
|
||||
types: [],
|
||||
structs: [
|
||||
{
|
||||
name: 'transfer',
|
||||
base: '',
|
||||
fields: [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'to',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
type: 'asset',
|
||||
},
|
||||
{
|
||||
name: 'memo',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
name: 'transfer',
|
||||
type: 'transfer',
|
||||
ricardian_contract: '',
|
||||
},
|
||||
],
|
||||
tables: [],
|
||||
ricardian_clauses: [],
|
||||
error_messages: [],
|
||||
abi_extensions: [],
|
||||
variants: [],
|
||||
action_results: [],
|
||||
}
|
||||
const testSession = new Session(mockSessionArgs, {
|
||||
...mockSessionOptions,
|
||||
abis: [
|
||||
{
|
||||
account: 'eosio.token',
|
||||
abi,
|
||||
},
|
||||
],
|
||||
})
|
||||
assert.lengthOf(testSession.abis, 1)
|
||||
})
|
||||
})
|
||||
suite('allowModify', function () {
|
||||
@@ -254,19 +314,23 @@ suite('session', function () {
|
||||
})
|
||||
suite('transactPlugins', function () {
|
||||
test('default', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
{
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
}
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
})
|
||||
@@ -275,39 +339,47 @@ suite('session', function () {
|
||||
assert.instanceOf(session.transactPlugins[0], BaseTransactPlugin)
|
||||
})
|
||||
test('inherit', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactPlugin()],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
{
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactPlugin()],
|
||||
}
|
||||
)
|
||||
const {session} = await sessionKit.login({permissionLevel: mockPermissionLevel})
|
||||
assert.instanceOf(session, Session)
|
||||
assert.lengthOf(session.transactPlugins, 1)
|
||||
assert.instanceOf(session.transactPlugins[0], MockTransactPlugin)
|
||||
})
|
||||
test('override', async function () {
|
||||
const sessionKit = new SessionKit({
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
{
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
}
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
transactPlugins: [new MockTransactPlugin()],
|
||||
@@ -345,7 +417,7 @@ suite('session', function () {
|
||||
actor: 'wharfkit1111',
|
||||
permission: 'test',
|
||||
walletPlugin: {
|
||||
id: 'keysigner',
|
||||
id: 'wallet-plugin-privatekey',
|
||||
data: {
|
||||
privateKey: 'PVT_K1_25XP1Lt1Rt87hyymouSieBbgnUEAerS1yQHi9wqHC2Uek2mgzH',
|
||||
},
|
||||
|
||||
+187
-50
@@ -1,32 +1,29 @@
|
||||
import {assert} from 'chai'
|
||||
import zlib from 'pako'
|
||||
|
||||
import {PermissionLevel, Serializer, Signature, TimePointSec} from '@greymass/eosio'
|
||||
import {ResolvedSigningRequest, SigningRequest} from 'eosio-signing-request'
|
||||
import {PermissionLevel, Serializer, Signature, TimePointSec, Transaction} from '@wharfkit/antelope'
|
||||
import {ResolvedSigningRequest, SigningRequest} from '@wharfkit/signing-request'
|
||||
|
||||
import SessionKit, {
|
||||
ABICache,
|
||||
ChainDefinition,
|
||||
Session,
|
||||
TransactContext,
|
||||
TransactHookTypes,
|
||||
} from '$lib'
|
||||
import SessionKit, {ChainDefinition, Session, TransactContext, TransactHookTypes} from '$lib'
|
||||
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {ABICache} from '@wharfkit/abicache'
|
||||
import {makeClient} from '@wharfkit/mock-data'
|
||||
import {mockFetch} from '@wharfkit/mock-data'
|
||||
import {
|
||||
mockMetadataFooWriterPlugin,
|
||||
mockTransactActionPrependerPlugin,
|
||||
MockTransactPlugin,
|
||||
MockTransactResourceProviderPlugin,
|
||||
} from '$test/utils/mock-hook'
|
||||
import {makeMockAction, makeMockActions, makeMockTransaction} from '$test/utils/mock-transfer'
|
||||
import {makeWallet} from '$test/utils/mock-wallet'
|
||||
import {mockPermissionLevel} from '$test/utils/mock-config'
|
||||
} from '@wharfkit/mock-data'
|
||||
import {makeMockAction, makeMockActions, makeMockTransaction} from '@wharfkit/mock-data'
|
||||
import {makeWallet} from '@wharfkit/mock-data'
|
||||
import {mockPermissionLevel} from '@wharfkit/mock-data'
|
||||
import {Transfer} from '$test/utils/setup/structs'
|
||||
import {mockSessionArgs, mockSessionOptions} from '$test/utils/mock-session'
|
||||
import {MockStorage} from '$test/utils/mock-storage'
|
||||
import {MockUserInterface} from '$test/utils/mock-userinterface'
|
||||
import {mockSessionArgs, mockSessionOptions} from '@wharfkit/mock-data'
|
||||
import {MockStorage} from '@wharfkit/mock-data'
|
||||
import {MockUserInterface} from '@wharfkit/mock-data'
|
||||
import {ContractKit} from '@wharfkit/contract'
|
||||
import {TransactPluginResourceProvider} from '@wharfkit/transact-plugin-resource-provider'
|
||||
|
||||
const client = makeClient()
|
||||
const wallet = makeWallet()
|
||||
@@ -68,6 +65,77 @@ suite('transact', function () {
|
||||
const result = await session.transact({action: Serializer.objectify(action)})
|
||||
assetValidTransactResponse(result)
|
||||
})
|
||||
test('from contract kit', async function () {
|
||||
const session = new Session(
|
||||
{
|
||||
...mockSessionArgs,
|
||||
permissionLevel: {
|
||||
actor: 'wharfkit1125',
|
||||
permission: 'test',
|
||||
},
|
||||
},
|
||||
mockSessionOptions
|
||||
)
|
||||
const kit = new ContractKit(
|
||||
{
|
||||
client,
|
||||
},
|
||||
{
|
||||
abiCache: session.abiCache,
|
||||
}
|
||||
)
|
||||
const contract = await kit.load('eosio')
|
||||
const action = contract.action('claimrewards', {owner: 'teamgreymass'})
|
||||
const result = await session.transact(
|
||||
{action},
|
||||
{transactPlugins: [new TransactPluginResourceProvider()]}
|
||||
)
|
||||
assert.isTrue(
|
||||
result.transaction?.actions[0].authorization[0].actor.equals('wharfkit1125')
|
||||
)
|
||||
assert.isTrue(
|
||||
result.transaction?.actions[0].authorization[0].permission.equals('test')
|
||||
)
|
||||
})
|
||||
test('from contract kit (to append to transaction)', async function () {
|
||||
const session = new Session(
|
||||
{
|
||||
...mockSessionArgs,
|
||||
permissionLevel: {
|
||||
actor: 'wharfkit1125',
|
||||
permission: 'test',
|
||||
},
|
||||
},
|
||||
mockSessionOptions
|
||||
)
|
||||
const kit = new ContractKit(
|
||||
{
|
||||
client,
|
||||
},
|
||||
{
|
||||
abiCache: session.abiCache,
|
||||
}
|
||||
)
|
||||
const contract = await kit.load('eosio')
|
||||
const action = contract.action('claimrewards', {owner: 'teamgreymass'})
|
||||
const info = await client.v1.chain.get_info()
|
||||
const header = info.getTransactionHeader()
|
||||
|
||||
const transaction = Transaction.from({
|
||||
...header,
|
||||
actions: [action],
|
||||
})
|
||||
const result = await session.transact(
|
||||
{transaction},
|
||||
{transactPlugins: [new TransactPluginResourceProvider()]}
|
||||
)
|
||||
assert.isTrue(
|
||||
result.transaction?.actions[0].authorization[0].actor.equals('wharfkit1125')
|
||||
)
|
||||
assert.isTrue(
|
||||
result.transaction?.actions[0].authorization[0].permission.equals('test')
|
||||
)
|
||||
})
|
||||
})
|
||||
suite('actions', function () {
|
||||
test('typed', async function () {
|
||||
@@ -158,11 +226,11 @@ suite('transact', function () {
|
||||
})
|
||||
test('object maintains payload metadata', async function () {
|
||||
const {action, session} = await mockData()
|
||||
const abiProvider = new ABICache(this.client)
|
||||
const abiCache = new ABICache(this.client)
|
||||
const request = await SigningRequest.create(
|
||||
{action},
|
||||
{
|
||||
abiProvider,
|
||||
abiProvider: abiCache,
|
||||
zlib,
|
||||
}
|
||||
)
|
||||
@@ -190,6 +258,67 @@ suite('transact', function () {
|
||||
})
|
||||
})
|
||||
suite('options', async function () {
|
||||
suite('abis', function () {
|
||||
test('passing as option', async function () {
|
||||
const {action, session} = await mockData()
|
||||
const abi = {
|
||||
version: 'eosio::abi/1.2',
|
||||
types: [],
|
||||
structs: [
|
||||
{
|
||||
name: 'transfer',
|
||||
base: '',
|
||||
fields: [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'to',
|
||||
type: 'name',
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
type: 'asset',
|
||||
},
|
||||
{
|
||||
name: 'memo',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
name: 'transfer',
|
||||
type: 'transfer',
|
||||
ricardian_contract: '',
|
||||
},
|
||||
],
|
||||
tables: [],
|
||||
ricardian_clauses: [],
|
||||
error_messages: [],
|
||||
abi_extensions: [],
|
||||
variants: [],
|
||||
action_results: [],
|
||||
}
|
||||
if (!abi) {
|
||||
assert.fail('No abi returned from get_abi')
|
||||
}
|
||||
const result = await session.transact(
|
||||
{action},
|
||||
{
|
||||
abis: [
|
||||
{
|
||||
account: 'eosio.token',
|
||||
abi,
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
assetValidTransactResponse(result)
|
||||
})
|
||||
})
|
||||
suite('allowModify', function () {
|
||||
test('default: true', async function () {
|
||||
const {action, session} = await mockData()
|
||||
@@ -400,23 +529,27 @@ suite('transact', function () {
|
||||
})
|
||||
test('kit constructor', async function () {
|
||||
const {action} = await mockData()
|
||||
const sessionKit = new SessionKit({
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactResourceProviderPlugin()],
|
||||
transactPluginsOptions: {
|
||||
disableExamplePlugin: true,
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
{
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactResourceProviderPlugin()],
|
||||
transactPluginsOptions: {
|
||||
disableExamplePlugin: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
})
|
||||
@@ -430,20 +563,24 @@ suite('transact', function () {
|
||||
})
|
||||
test('login', async function () {
|
||||
const {action} = await mockData()
|
||||
const sessionKit = new SessionKit({
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactResourceProviderPlugin()],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
})
|
||||
const sessionKit = new SessionKit(
|
||||
{
|
||||
appName: 'demo.app',
|
||||
chains: [
|
||||
{
|
||||
id: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
url: 'https://jungle4.greymass.com',
|
||||
},
|
||||
],
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
},
|
||||
{
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
transactPlugins: [new MockTransactResourceProviderPlugin()],
|
||||
}
|
||||
)
|
||||
const {session} = await sessionKit.login({
|
||||
permissionLevel: mockPermissionLevel,
|
||||
transactPluginsOptions: {
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import {LocaleDefinitions} from 'src/types'
|
||||
import {UserInterface, UserInterfaceTranslateOptions} from 'src/ui'
|
||||
import type {LocaleDefinitions} from '@wharfkit/common'
|
||||
import {MockUserInterface} from '@wharfkit/mock-data'
|
||||
|
||||
import {MockUserInterface} from '$test/utils/mock-userinterface'
|
||||
import {UserInterface, UserInterfaceTranslateOptions} from 'src/ui'
|
||||
|
||||
const mockLocaleDefinitions: LocaleDefinitions = {
|
||||
en: {
|
||||
|
||||
@@ -20,8 +20,8 @@ import {
|
||||
mockPermissionName,
|
||||
mockPrivateKey,
|
||||
mockUrl,
|
||||
} from '$test/utils/mock-config'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
} from '@wharfkit/mock-data'
|
||||
import {mockFetch} from '@wharfkit/mock-data'
|
||||
|
||||
/**
|
||||
* Required arguments for manually establishing a session.
|
||||
|
||||
+3
-3
@@ -3,11 +3,11 @@ import {assert} from 'chai'
|
||||
import zlib from 'pako'
|
||||
|
||||
import {ChainDefinition, Logo, SigningRequest, Transaction} from '$lib'
|
||||
import {makeMockAction} from '$test/utils/mock-transfer'
|
||||
import {makeMockAction} from '@wharfkit/mock-data'
|
||||
|
||||
import {appendAction, prependAction} from 'src/utils'
|
||||
import {mockData} from '$test/utils/mock-data'
|
||||
import {mockChainId} from '$test/utils/mock-config'
|
||||
import {mockData} from '@wharfkit/mock-data'
|
||||
import {mockChainId} from '@wharfkit/mock-data'
|
||||
|
||||
const newAction = makeMockAction('new action')
|
||||
|
||||
|
||||
+123
-68
@@ -1,12 +1,18 @@
|
||||
import {assert} from 'chai'
|
||||
|
||||
import SessionKit, {ChainDefinition, Logo, SessionKitOptions, WalletPluginMetadata} from '$lib'
|
||||
import {MockUserInterface} from '$test/utils/mock-userinterface'
|
||||
import {makeWallet, MockWalletPluginConfigs} from '$test/utils/mock-wallet'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {makeMockAction} from '$test/utils/mock-transfer'
|
||||
import {MockStorage} from '$test/utils/mock-storage'
|
||||
import {mockChainDefinitions, mockPrivateKey} from '$test/utils/mock-config'
|
||||
import SessionKit, {
|
||||
ChainDefinition,
|
||||
Logo,
|
||||
SessionKitArgs,
|
||||
SessionKitOptions,
|
||||
WalletPluginMetadata,
|
||||
} from '$lib'
|
||||
import {MockUserInterface} from '@wharfkit/mock-data'
|
||||
import {makeWallet, MockWalletPluginConfigs} from '@wharfkit/mock-data'
|
||||
import {mockFetch} from '@wharfkit/mock-data'
|
||||
import {makeMockAction} from '@wharfkit/mock-data'
|
||||
import {MockStorage} from '@wharfkit/mock-data'
|
||||
import {mockChainDefinitions, mockPrivateKey} from '@wharfkit/mock-data'
|
||||
|
||||
const chains = [
|
||||
ChainDefinition.from({
|
||||
@@ -27,15 +33,18 @@ const chains = [
|
||||
}),
|
||||
]
|
||||
|
||||
const defaultSessionKitOptions: SessionKitOptions = {
|
||||
const defaultSessionKitArgs: SessionKitArgs = {
|
||||
appName: 'demo.app',
|
||||
chains,
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [makeWallet()],
|
||||
}
|
||||
|
||||
const defaultSessionKitOptions: SessionKitOptions = {
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
}
|
||||
|
||||
suite('walletPlugin', function () {
|
||||
suite('config', function () {
|
||||
test('defaults', function () {
|
||||
@@ -67,10 +76,13 @@ suite('walletPlugin', function () {
|
||||
requiresPermissionSelect: false,
|
||||
})
|
||||
assert.isTrue(walletPlugin.config.requiresChainSelect)
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const result = await kit.login({
|
||||
permissionLevel: 'mock@interface',
|
||||
})
|
||||
@@ -84,10 +96,13 @@ suite('walletPlugin', function () {
|
||||
requiresPermissionSelect: false,
|
||||
})
|
||||
assert.isFalse(walletPlugin.config.requiresChainSelect)
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const result = await kit.login({
|
||||
permissionLevel: 'mock@interface',
|
||||
})
|
||||
@@ -103,10 +118,13 @@ suite('walletPlugin', function () {
|
||||
requiresPermissionSelect: true,
|
||||
})
|
||||
assert.isTrue(walletPlugin.config.requiresPermissionSelect)
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const result = await kit.login({
|
||||
chain: chains[0].id,
|
||||
})
|
||||
@@ -120,10 +138,13 @@ suite('walletPlugin', function () {
|
||||
requiresPermissionSelect: false,
|
||||
})
|
||||
assert.isFalse(walletPlugin.config.requiresPermissionSelect)
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const result = await kit.login({
|
||||
chain: chains[0].id,
|
||||
})
|
||||
@@ -141,10 +162,13 @@ suite('walletPlugin', function () {
|
||||
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
],
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
await kit.login({
|
||||
permissionLevel: 'mock@interface',
|
||||
})
|
||||
@@ -157,10 +181,13 @@ suite('walletPlugin', function () {
|
||||
'f16b1833c747c43682f4386fca9cbb327929334a762755ebec17f6f23c9b8a12', // WAX (Testnet)
|
||||
],
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
let error
|
||||
try {
|
||||
await kit.login({
|
||||
@@ -180,10 +207,13 @@ suite('walletPlugin', function () {
|
||||
'34593b65376aee3c9b06ea8a8595122b39333aaab4c76ad52587831fcc096590', // mockUserInterface Default
|
||||
],
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
await kit.login({
|
||||
chain: '34593b65376aee3c9b06ea8a8595122b39333aaab4c76ad52587831fcc096590',
|
||||
permissionLevel: 'mock@interface',
|
||||
@@ -197,10 +227,13 @@ suite('walletPlugin', function () {
|
||||
'f16b1833c747c43682f4386fca9cbb327929334a762755ebec17f6f23c9b8a12', // WAX (Testnet)
|
||||
],
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
let error
|
||||
try {
|
||||
await kit.login({
|
||||
@@ -219,10 +252,13 @@ suite('walletPlugin', function () {
|
||||
testModify: true,
|
||||
privateKey: mockPrivateKey,
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const loginResult = await kit.login({
|
||||
chain: chains[0].id,
|
||||
permissionLevel: 'mock@interface',
|
||||
@@ -233,11 +269,16 @@ suite('walletPlugin', function () {
|
||||
const walletPlugin = new MockWalletPluginConfigs(undefined, {
|
||||
testModify: true,
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
allowModify: false,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
{
|
||||
...defaultSessionKitOptions,
|
||||
allowModify: false,
|
||||
}
|
||||
)
|
||||
const loginResult = await kit.login({
|
||||
chain: chains[0].id,
|
||||
permissionLevel: 'mock@interface',
|
||||
@@ -258,11 +299,16 @@ suite('walletPlugin', function () {
|
||||
testModify: true,
|
||||
privateKey: mockPrivateKey,
|
||||
})
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
allowModify: true,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
{
|
||||
...defaultSessionKitOptions,
|
||||
allowModify: true,
|
||||
}
|
||||
)
|
||||
const loginResult = await kit.login({
|
||||
chain: chains[0].id,
|
||||
permissionLevel: 'mock@interface',
|
||||
@@ -274,10 +320,13 @@ suite('walletPlugin', function () {
|
||||
suite('storage', function () {
|
||||
test('empty data', async function () {
|
||||
const walletPlugin = new MockWalletPluginConfigs()
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const response = await kit.login()
|
||||
assert.deepEqual(response.session.serialize(), {
|
||||
chain: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
@@ -299,10 +348,13 @@ suite('walletPlugin', function () {
|
||||
foo: 'baz',
|
||||
}
|
||||
)
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const response = await kit.login()
|
||||
assert.deepEqual(response.session.serialize(), {
|
||||
chain: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d',
|
||||
@@ -329,10 +381,13 @@ suite('walletPlugin', function () {
|
||||
},
|
||||
}
|
||||
const walletPlugin = new MockWalletPluginConfigs()
|
||||
const kit = new SessionKit({
|
||||
...defaultSessionKitOptions,
|
||||
walletPlugins: [walletPlugin],
|
||||
})
|
||||
const kit = new SessionKit(
|
||||
{
|
||||
...defaultSessionKitArgs,
|
||||
walletPlugins: [walletPlugin],
|
||||
},
|
||||
defaultSessionKitOptions
|
||||
)
|
||||
const session = await kit.restore(serializedSession)
|
||||
if (!session) {
|
||||
throw new Error('Failed to restore session')
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import {Bytes, Checksum160} from '@greymass/eosio'
|
||||
|
||||
const data = global.MOCK_DATA
|
||||
|
||||
export function getFilename(path, params) {
|
||||
const digest = Checksum160.hash(
|
||||
Bytes.from(path + (params ? JSON.stringify(params) : ''), 'utf8')
|
||||
).hexString
|
||||
return digest + '.json'
|
||||
}
|
||||
|
||||
async function getExisting(filename) {
|
||||
return data[filename]
|
||||
}
|
||||
|
||||
export async function mockFetch(path, params) {
|
||||
const filename = getFilename(path, params)
|
||||
const existing = await getExisting(filename)
|
||||
if (existing) {
|
||||
return new Response(existing.text, {
|
||||
status: existing.status,
|
||||
headers: existing.headers,
|
||||
})
|
||||
}
|
||||
throw new Error(`No data for ${path}`)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import {APIClient, FetchProvider} from '@greymass/eosio'
|
||||
|
||||
import {mockUrl} from './mock-config'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
|
||||
export function makeClient(url?: string) {
|
||||
return new APIClient({
|
||||
provider: new FetchProvider(url || mockUrl, {fetch: mockFetch}),
|
||||
})
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
export const mockChainId = '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
|
||||
export const mockUrl = 'https://jungle4.greymass.com'
|
||||
export const mockChainDefinition = {
|
||||
id: mockChainId,
|
||||
url: mockUrl,
|
||||
}
|
||||
export const mockChainDefinitions = [
|
||||
mockChainDefinition,
|
||||
{
|
||||
id: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
|
||||
url: 'https://eos.greymass.com',
|
||||
},
|
||||
{
|
||||
id: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
|
||||
url: 'https://telos.greymass.com',
|
||||
},
|
||||
{
|
||||
id: '1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4',
|
||||
url: 'https://wax.greymass.com',
|
||||
},
|
||||
{
|
||||
id: '34593b65376aee3c9b06ea8a8595122b39333aaab4c76ad52587831fcc096590',
|
||||
url: 'https://mockuserinterface.greymass.com',
|
||||
},
|
||||
]
|
||||
export const mockPrivateKey = '5Jtoxgny5tT7NiNFp1MLogviuPJ9NniWjnU4wKzaX4t7pL4kJ8s'
|
||||
export const mockAccountName = 'wharfkit1111'
|
||||
export const mockPermissionName = 'test'
|
||||
export const mockPermissionLevel = `${mockAccountName}@${mockPermissionName}`
|
||||
@@ -1,35 +0,0 @@
|
||||
import {
|
||||
ABICache,
|
||||
ChainDefinition,
|
||||
Session,
|
||||
SigningRequest,
|
||||
TransactArgs,
|
||||
TransactContext,
|
||||
TransactContextOptions,
|
||||
} from '$lib'
|
||||
import {APIClient, FetchProvider, PermissionLevel} from '@greymass/eosio'
|
||||
|
||||
import {mockChainDefinition, mockUrl} from './mock-config'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {mockSession, mockSessionArgs, mockSessionOptions} from './mock-session'
|
||||
|
||||
const client = new APIClient({
|
||||
provider: new FetchProvider(mockUrl, {fetch: mockFetch}),
|
||||
})
|
||||
|
||||
const session = new Session(mockSessionArgs, mockSessionOptions)
|
||||
const abiProvider = new ABICache(client)
|
||||
|
||||
export const mockTransactContextOptions: TransactContextOptions = {
|
||||
abiProvider,
|
||||
chain: ChainDefinition.from(mockChainDefinition),
|
||||
client,
|
||||
createRequest: async (args: TransactArgs): Promise<SigningRequest> =>
|
||||
session.createRequest(args, abiProvider),
|
||||
fetch: mockFetch,
|
||||
permissionLevel: PermissionLevel.from('wharfkit1125@test'),
|
||||
}
|
||||
|
||||
export function makeContext(): TransactContext {
|
||||
return new TransactContext(mockTransactContextOptions)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import {Session} from '$lib'
|
||||
|
||||
import {makeClient} from '$test/utils/mock-client'
|
||||
import {mockSessionArgs, mockSessionOptions} from './mock-session'
|
||||
import {makeMockAction, makeMockActions, makeMockTransaction} from '$test/utils/mock-transfer'
|
||||
|
||||
const client = makeClient()
|
||||
|
||||
export async function mockData(memo?: string) {
|
||||
const info = await client.v1.chain.get_info()
|
||||
const action = await makeMockAction(memo)
|
||||
const actions = await makeMockActions(memo)
|
||||
const transaction = await makeMockTransaction(info, memo)
|
||||
const session = new Session(mockSessionArgs, mockSessionOptions)
|
||||
return {
|
||||
action,
|
||||
actions,
|
||||
info,
|
||||
session,
|
||||
transaction,
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
import fetch, {Response} from 'node-fetch'
|
||||
import {join as joinPath} from 'path'
|
||||
import {promisify} from 'util'
|
||||
import {readFile as _readFile, writeFile as _writeFile} from 'fs'
|
||||
import {Bytes, Checksum160} from '@greymass/eosio'
|
||||
|
||||
const readFile = promisify(_readFile)
|
||||
const writeFile = promisify(_writeFile)
|
||||
|
||||
function getFilename(path: string, params?: unknown) {
|
||||
const digest = Checksum160.hash(
|
||||
Bytes.from(path + (params ? JSON.stringify(params) : ''), 'utf8')
|
||||
).hexString
|
||||
return joinPath(__dirname, '../data', digest + '.json')
|
||||
}
|
||||
|
||||
async function getExisting(filename: string) {
|
||||
try {
|
||||
const data = await readFile(filename)
|
||||
return JSON.parse(data.toString('utf8'))
|
||||
} catch (error) {
|
||||
if ((<any>error).code !== 'ENOENT') {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function mockFetch(path, params) {
|
||||
if (process.env['LOGHTTP']) {
|
||||
console.log('HTTP Request', {path, params})
|
||||
}
|
||||
const filename = getFilename(path, params)
|
||||
if (process.env['MOCK'] !== 'overwrite') {
|
||||
const existing = await getExisting(filename)
|
||||
if (existing) {
|
||||
return new Response(existing.text, {
|
||||
status: existing.status,
|
||||
headers: existing.headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
if (process.env['MOCK']) {
|
||||
const response = await fetch(path, params)
|
||||
const json = await response.clone().json()
|
||||
await writeFile(
|
||||
filename,
|
||||
JSON.stringify(
|
||||
{
|
||||
request: {
|
||||
path,
|
||||
params,
|
||||
},
|
||||
headers: Object.fromEntries(response.headers.entries()),
|
||||
status: response.status,
|
||||
json,
|
||||
text: JSON.stringify(json),
|
||||
},
|
||||
undefined,
|
||||
4
|
||||
)
|
||||
)
|
||||
return response
|
||||
} else {
|
||||
throw new Error(`No data for ${path}`)
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import {
|
||||
AbstractTransactPlugin,
|
||||
Action,
|
||||
LoginHook,
|
||||
SessionOptions,
|
||||
SigningRequest,
|
||||
Struct,
|
||||
TransactContext,
|
||||
TransactHookResponse,
|
||||
TransactHookTypes,
|
||||
Transaction,
|
||||
} from '$lib'
|
||||
import {prependAction} from 'src/utils'
|
||||
|
||||
export async function mockLoginHook(context: SessionOptions) {
|
||||
// Mock hook that does nothing
|
||||
}
|
||||
|
||||
export async function mockTransactHook(request: SigningRequest): Promise<TransactHookResponse> {
|
||||
// Mock hook that does nothing
|
||||
return {
|
||||
request,
|
||||
signatures: [],
|
||||
}
|
||||
}
|
||||
|
||||
export class MockTransactPlugin extends AbstractTransactPlugin {
|
||||
id = 'mock-transact-plugin'
|
||||
register(context: TransactContext): void {
|
||||
context.addHook(TransactHookTypes.beforeSign, mockTransactHook)
|
||||
context.addHook(TransactHookTypes.afterSign, mockTransactHook)
|
||||
context.addHook(TransactHookTypes.afterBroadcast, mockTransactHook)
|
||||
}
|
||||
}
|
||||
|
||||
// Needed to load the ABI and work with an `Action` object
|
||||
class noop extends Struct {
|
||||
static abiName = 'noop'
|
||||
static abiFields = []
|
||||
}
|
||||
|
||||
export async function mockTransactResourceProviderPresignHook(
|
||||
request: SigningRequest,
|
||||
context: TransactContext
|
||||
): Promise<TransactHookResponse> {
|
||||
// Pull the plugin options from the context
|
||||
const options = context.transactPluginsOptions
|
||||
// If any options this plugin is interested in are set, react to them
|
||||
// In this example, we're just bypassing the plugin w/ a flag.
|
||||
if (options.disableExamplePlugin) {
|
||||
return {
|
||||
request,
|
||||
signatures: [],
|
||||
}
|
||||
}
|
||||
const newAction = Action.from({
|
||||
account: 'greymassnoop',
|
||||
name: 'noop',
|
||||
authorization: [
|
||||
{
|
||||
actor: 'greymassfuel',
|
||||
permission: 'cosign',
|
||||
},
|
||||
],
|
||||
data: noop.from({}),
|
||||
})
|
||||
const modified = prependAction(request, newAction)
|
||||
// Return the request
|
||||
return {
|
||||
request: modified,
|
||||
signatures: [],
|
||||
}
|
||||
}
|
||||
|
||||
export class MockTransactResourceProviderPlugin extends AbstractTransactPlugin {
|
||||
id = 'mock-transact-resource-provider-plugin'
|
||||
register(context: TransactContext): void {
|
||||
context.addHook(TransactHookTypes.beforeSign, mockTransactResourceProviderPresignHook)
|
||||
}
|
||||
}
|
||||
|
||||
export const mockTransactActionPrependerPlugin = {
|
||||
id: 'mock-transact-action-prepender-plugin',
|
||||
register: (context) =>
|
||||
context.addHook(TransactHookTypes.beforeSign, async (request, context) => ({
|
||||
request: await SigningRequest.create(
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
account: 'greymassnoop',
|
||||
name: 'noop',
|
||||
authorization: [
|
||||
{
|
||||
actor: [...Array(12)]
|
||||
.map(() => Math.random().toString(36)[2])
|
||||
.join(''),
|
||||
permission: 'test',
|
||||
},
|
||||
],
|
||||
data: {},
|
||||
},
|
||||
...request.getRawActions(),
|
||||
],
|
||||
},
|
||||
context.esrOptions
|
||||
),
|
||||
})),
|
||||
}
|
||||
|
||||
export const mockMetadataFooWriterPlugin = {
|
||||
id: 'mock-metadata-foo-writer-plugin',
|
||||
register: (context) =>
|
||||
context.addHook(TransactHookTypes.beforeSign, async (request) => {
|
||||
request.setInfoKey('foo', 'baz')
|
||||
return {
|
||||
request,
|
||||
}
|
||||
}),
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import {PermissionLevel} from '@greymass/eosio'
|
||||
|
||||
import {Session, SessionArgs, SessionKit, SessionKitOptions, SessionOptions} from '$lib'
|
||||
|
||||
import {
|
||||
mockChainDefinition,
|
||||
mockChainDefinitions,
|
||||
mockPermissionLevel,
|
||||
} from '$test/utils/mock-config'
|
||||
import {mockFetch} from '$test/utils/mock-fetch'
|
||||
import {makeWallet} from '$test/utils/mock-wallet'
|
||||
import {MockStorage} from './mock-storage'
|
||||
import {MockUserInterface} from './mock-userinterface'
|
||||
|
||||
const wallet = makeWallet()
|
||||
|
||||
export const mockSessionKitOptions: SessionKitOptions = {
|
||||
appName: 'unittest',
|
||||
chains: mockChainDefinitions,
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
storage: new MockStorage(),
|
||||
ui: new MockUserInterface(),
|
||||
walletPlugins: [wallet],
|
||||
}
|
||||
|
||||
export const mockSessionKit = new SessionKit(mockSessionKitOptions)
|
||||
|
||||
export const mockSessionArgs: SessionArgs = {
|
||||
chain: mockChainDefinition,
|
||||
permissionLevel: PermissionLevel.from(mockPermissionLevel),
|
||||
walletPlugin: wallet,
|
||||
}
|
||||
|
||||
export const mockSessionOptions: SessionOptions = {
|
||||
broadcast: false, // Disable broadcasting by default for tests, enable when required.
|
||||
fetch: mockFetch, // Required for unit tests
|
||||
}
|
||||
|
||||
export const mockSession = new Session(mockSessionArgs, mockSessionOptions)
|
||||
@@ -1,17 +0,0 @@
|
||||
import {SessionStorage} from 'src/storage'
|
||||
|
||||
export class MockStorage implements SessionStorage {
|
||||
data: Record<string, string> = {}
|
||||
async write(key: string, data: string): Promise<void> {
|
||||
this.data[key] = data
|
||||
}
|
||||
async read(key: string): Promise<string | null> {
|
||||
return this.data[key]
|
||||
}
|
||||
async remove(key: string): Promise<void> {
|
||||
delete this.data[key]
|
||||
}
|
||||
storageKey(key: string) {
|
||||
return `mock-${key}`
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import {Action, API, Asset, Name, Struct, Transaction} from '@greymass/eosio'
|
||||
|
||||
import {mockAccountName, mockPermissionName} from './mock-config'
|
||||
|
||||
@Struct.type('transfer')
|
||||
class Transfer extends Struct {
|
||||
@Struct.field('name') from!: Name
|
||||
@Struct.field('name') to!: Name
|
||||
@Struct.field('asset') quantity!: Asset
|
||||
@Struct.field('string') memo!: string
|
||||
}
|
||||
|
||||
export function makeMockAction(memo?: string): Action {
|
||||
// Generate typed data for action data
|
||||
const transfer = Transfer.from({
|
||||
from: mockAccountName,
|
||||
to: 'teamgreymass',
|
||||
quantity: '0.1337 EOS',
|
||||
memo: memo || 'wharfkit is the best <3',
|
||||
})
|
||||
// Assemble action with action data and metadata
|
||||
const action = Action.from({
|
||||
authorization: [
|
||||
{
|
||||
actor: mockAccountName,
|
||||
permission: mockPermissionName,
|
||||
},
|
||||
],
|
||||
account: 'eosio.token',
|
||||
name: 'transfer',
|
||||
data: transfer,
|
||||
})
|
||||
return action
|
||||
}
|
||||
|
||||
export function makeMockActions(memo?: string): Action[] {
|
||||
return [makeMockAction(memo)]
|
||||
}
|
||||
|
||||
export function makeMockTransaction(info: API.v1.GetInfoResponse, memo?: string): Transaction {
|
||||
// Assemble transaction header
|
||||
const header = info.getTransactionHeader(90)
|
||||
// Generate array of actions
|
||||
const actions = makeMockActions(memo)
|
||||
// Form and return transaction object
|
||||
const transaction = Transaction.from({
|
||||
...header,
|
||||
actions,
|
||||
})
|
||||
return transaction
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
import {
|
||||
AbstractUserInterface,
|
||||
cancelable,
|
||||
Cancelable,
|
||||
Checksum256,
|
||||
LocaleDefinitions,
|
||||
LoginContext,
|
||||
LoginOptions,
|
||||
PermissionLevel,
|
||||
PromptArgs,
|
||||
PromptResponse,
|
||||
UserInterface,
|
||||
UserInterfaceLoginResponse,
|
||||
} from '$lib'
|
||||
|
||||
export class MockUserInterface extends AbstractUserInterface implements UserInterface {
|
||||
readonly logging = false
|
||||
public messages: string[] = []
|
||||
public localeDefinitions: LocaleDefinitions = {}
|
||||
|
||||
log(message: string) {
|
||||
this.messages.push(message)
|
||||
if (this.logging) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info('MockUserInterface', message)
|
||||
}
|
||||
}
|
||||
|
||||
async login(context: LoginContext): Promise<UserInterfaceLoginResponse> {
|
||||
let chainId = context.chain?.id
|
||||
if (!chainId) {
|
||||
chainId = Checksum256.from(context.chains[0].id)
|
||||
}
|
||||
let permissionLevel = context.permissionLevel
|
||||
if (!permissionLevel) {
|
||||
permissionLevel = PermissionLevel.from('mock@interface')
|
||||
}
|
||||
return {
|
||||
chainId,
|
||||
permissionLevel,
|
||||
walletPluginIndex: 0,
|
||||
}
|
||||
}
|
||||
|
||||
async onError(error: Error) {
|
||||
this.log('onError: ' + JSON.stringify(error))
|
||||
}
|
||||
|
||||
async onLogin(options?: LoginOptions) {
|
||||
this.log('onLogin: ' + JSON.stringify(options))
|
||||
}
|
||||
|
||||
async onLoginComplete() {
|
||||
this.log('onLoginComplete')
|
||||
}
|
||||
|
||||
async onTransact() {
|
||||
this.log('onTransact')
|
||||
}
|
||||
|
||||
async onTransactComplete() {
|
||||
this.log('onTransactComplete')
|
||||
}
|
||||
|
||||
async onSign() {
|
||||
this.log('onSign')
|
||||
}
|
||||
|
||||
async onSignComplete() {
|
||||
this.log('onSignComplete')
|
||||
}
|
||||
|
||||
async onBroadcast() {
|
||||
this.log('onBroadcast')
|
||||
}
|
||||
|
||||
async onBroadcastComplete() {
|
||||
this.log('onBroadcastComplete')
|
||||
}
|
||||
|
||||
prompt(args: PromptArgs): Cancelable<PromptResponse> {
|
||||
this.log('prompt' + JSON.stringify(args))
|
||||
return cancelable(new Promise(() => {}), (canceled) => {
|
||||
// do things to cancel promise
|
||||
throw canceled
|
||||
})
|
||||
}
|
||||
|
||||
status(message: string) {
|
||||
this.log(`status:('${message}')`)
|
||||
}
|
||||
|
||||
addTranslations(definitions: LocaleDefinitions): void {
|
||||
this.log('addTranslations: ' + JSON.stringify(definitions))
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import {Checksum256, PermissionLevel, PrivateKey, Transaction} from '@greymass/eosio'
|
||||
import {WalletPluginPrivateKey} from '@wharfkit/wallet-plugin-privatekey'
|
||||
|
||||
import {
|
||||
AbstractWalletPlugin,
|
||||
ChainDefinition,
|
||||
LoginContext,
|
||||
ResolvedSigningRequest,
|
||||
SigningRequest,
|
||||
TransactContext,
|
||||
WalletPluginConfig,
|
||||
WalletPluginData,
|
||||
WalletPluginMetadata,
|
||||
WalletPluginSignResponse,
|
||||
} from '$lib'
|
||||
import {mockChainDefinition, mockPermissionLevel, mockPrivateKey} from './mock-config'
|
||||
import {makeMockAction} from './mock-transfer'
|
||||
|
||||
export function makeWallet() {
|
||||
return new WalletPluginPrivateKey(PrivateKey.from(mockPrivateKey))
|
||||
}
|
||||
|
||||
export class MockWalletPluginConfigs extends AbstractWalletPlugin {
|
||||
readonly metadata = WalletPluginMetadata.from({
|
||||
name: 'Mock Wallet Plugin',
|
||||
description: 'A mock wallet plugin for testing chain selection',
|
||||
logo: 'https://assets.wharfkit.com/chain/jungle.png',
|
||||
})
|
||||
testModify = false
|
||||
config: WalletPluginConfig
|
||||
constructor(config?: WalletPluginConfig, initialData: WalletPluginData = {}) {
|
||||
super()
|
||||
if (config) {
|
||||
this.config = config
|
||||
} else {
|
||||
this.config = {
|
||||
requiresChainSelect: true,
|
||||
requiresPermissionSelect: false,
|
||||
}
|
||||
}
|
||||
this.data = initialData
|
||||
}
|
||||
get id() {
|
||||
return 'MockWalletPluginConfigs'
|
||||
}
|
||||
async login(context: LoginContext) {
|
||||
// Return the chain and permission level for this fake wallet
|
||||
return {
|
||||
chain: context.chain ? context.chain.id : ChainDefinition.from(mockChainDefinition).id,
|
||||
permissionLevel: context.permissionLevel || PermissionLevel.from(mockPermissionLevel),
|
||||
}
|
||||
}
|
||||
async sign(
|
||||
resolved: ResolvedSigningRequest,
|
||||
context: TransactContext
|
||||
): Promise<WalletPluginSignResponse> {
|
||||
if (context.storage) {
|
||||
context.storage.write('testModify', this.data.testModify)
|
||||
}
|
||||
// If the `testModify` flag is enabled, modify the transaction for testing purposes
|
||||
if (this.data.testModify) {
|
||||
const request = await SigningRequest.create(
|
||||
{action: makeMockAction('modified transaction')},
|
||||
context.esrOptions
|
||||
)
|
||||
const resolved = await context.resolve(request)
|
||||
const transaction = Transaction.from(resolved.transaction)
|
||||
const digest = transaction.signingDigest(Checksum256.from(context.chain.id))
|
||||
const privateKey = PrivateKey.from(this.data.privateKey)
|
||||
const signature = privateKey.signDigest(digest)
|
||||
return {
|
||||
resolved: resolved,
|
||||
signatures: [signature],
|
||||
}
|
||||
}
|
||||
// Otherwise sign what was returned
|
||||
const transaction = Transaction.from(resolved.transaction)
|
||||
const digest = transaction.signingDigest(Checksum256.from(context.chain.id))
|
||||
const privateKey = PrivateKey.from(this.data.privateKey)
|
||||
const signature = privateKey.signDigest(digest)
|
||||
return {
|
||||
signatures: [signature],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import {Action, AssetType, Name, NameType, PermissionLevel, Session, TransactRes
|
||||
import {Buyrambytes, Delegatebw, Linkauth, Newaccount, Transfer, Updateauth} from './structs'
|
||||
|
||||
// Mock of Fetch for debugging/testing
|
||||
// import {mockFetch} from '$test/utils/mock-fetch'
|
||||
// import {mockFetch} from '@wharfkit/mock-data'
|
||||
|
||||
/**
|
||||
* THIS INFORMATION NEEDS TO BE POPULATED
|
||||
@@ -25,7 +25,7 @@ const controlKey = 'EOS6XXTaRpWhPwnb7CTV9zVsCBrvCpYMMPSk8E8hsJxhf6VFW9DYN'
|
||||
const testKey = 'EOS6RMS3nvoN9StPzZizve6WdovaDkE5KkEcCDXW7LbepyAioMiK6'
|
||||
|
||||
// Cosigner Key for wharfkitnoop
|
||||
const noopKey = 'EOS8WUgppBZ1NjnGASYeLwQ3PkNLvdnfnchumsSpo6ApCAzbETczm'
|
||||
// const noopKey = 'EOS8WUgppBZ1NjnGASYeLwQ3PkNLvdnfnchumsSpo6ApCAzbETczm'
|
||||
|
||||
// Minimum RAM bytes to create an account
|
||||
const requiredRamBytes = 1599
|
||||
@@ -406,10 +406,12 @@ async function run() {
|
||||
// Check if account exists
|
||||
try {
|
||||
await masterSession.client.v1.chain.get_account(Name.from(account.name))
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`account ${account.name} already exists`)
|
||||
} catch (e) {
|
||||
// Create account
|
||||
const result = await createAccount(masterSession, account)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`created ${account.name} ${result.resolved?.transaction.id}`)
|
||||
}
|
||||
}
|
||||
@@ -423,9 +425,11 @@ async function run() {
|
||||
return String(permission.perm_name) === 'test'
|
||||
})
|
||||
if (hasTestPermission) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`account ${account.name} already has test permission...`)
|
||||
} else {
|
||||
const result = await createTestPermission(account)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
`created test permission on ${account.name} ${result.resolved?.transaction.id}}`
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Asset, Name, PublicKey, Struct, UInt16, UInt32} from '@greymass/eosio'
|
||||
import {Asset, Name, PublicKey, Struct, UInt16, UInt32} from '@wharfkit/antelope'
|
||||
|
||||
@Struct.type('key_weight')
|
||||
export class KeyWeight extends Struct {
|
||||
|
||||
@@ -926,17 +926,6 @@
|
||||
minimatch "^3.1.2"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@greymass/eosio@^0.6.0", "@greymass/eosio@^0.6.10":
|
||||
version "0.6.10"
|
||||
resolved "https://registry.yarnpkg.com/@greymass/eosio/-/eosio-0.6.10.tgz#20028c2f71da8c071e0a78959904660fa54e1182"
|
||||
integrity sha512-lgml9eAR85q1s3cDSFiipK1XensUASpBWPU6vu3FRDot0CBOC46kHnNWXjF9p+/jI2TzxFqPVU185ZxzC9Q3mw==
|
||||
dependencies:
|
||||
bn.js "^4.11.9"
|
||||
brorand "^1.1.0"
|
||||
elliptic "^6.5.4"
|
||||
hash.js "^1.0.0"
|
||||
tslib "^2.0.3"
|
||||
|
||||
"@humanwhocodes/config-array@^0.11.6":
|
||||
version "0.11.7"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f"
|
||||
@@ -1272,10 +1261,86 @@
|
||||
"@typescript-eslint/types" "5.45.0"
|
||||
eslint-visitor-keys "^3.3.0"
|
||||
|
||||
"@wharfkit/wallet-plugin-privatekey@^0.3.0-ui-13":
|
||||
version "0.3.0-ui-13"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-0.3.0-ui-13.tgz#ac8875bc78f275254b3dca827e2b356670971e62"
|
||||
integrity sha512-jYFBdpQsKrG4Mh5540XyCR72TifHuljivdOIv+gdi+jKnmEQzsiEd4ac8mlIdOgqkL+JFoHQWnHeVO87Agg39w==
|
||||
"@wharfkit/abicache@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.1.1.tgz#03624d03d9466e7def278786aaf074d274fc5650"
|
||||
integrity sha512-CfpHzCLxFATcfReqdJDUxEDSHIeBF3jFx0cP8RcTDyhC2jX4cd+Q/wqjw/kCni3xrBM7cIGUp9c9NZdvdTK9Cg==
|
||||
dependencies:
|
||||
"@wharfkit/antelope" "^0.7.3"
|
||||
"@wharfkit/signing-request" "^3.0.0"
|
||||
pako "^2.0.4"
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/antelope@^0.7.3":
|
||||
version "0.7.3"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-0.7.3.tgz#408f6c587f4f5990d4b55596c10be2e976798641"
|
||||
integrity sha512-pyUmuXUpLQh1RVpJVIcbVUHTwV/DQ+MI0nlfWDBHIICdYf6XidZtQmaHB7JEXiFzlS8T7S9Xc5VOTOQU8dnl3Q==
|
||||
dependencies:
|
||||
bn.js "^4.11.9"
|
||||
brorand "^1.1.0"
|
||||
elliptic "^6.5.4"
|
||||
hash.js "^1.0.0"
|
||||
tslib "^2.0.3"
|
||||
|
||||
"@wharfkit/common@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/common/-/common-1.1.0.tgz#1ee9dd1ba9e202002fadd20593f5f42a3e67c827"
|
||||
integrity sha512-A1Ta8zrEXkuEQcEiEexG0BVrYOxqm75qbLYU9tGNhyw4z/vQiF6rzmCOqhmWGg6nE2J2GYPvrPZPZzDmRGtG+w==
|
||||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/contract@^0.3.3":
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/contract/-/contract-0.3.3.tgz#4bdc0a02d574be5281160f7c35afde607fcba3d4"
|
||||
integrity sha512-idzn0PLU0M7ZfcUe2NqYLRmf4iuzEcxUFr9h9vikuvQLbfLo+g9Xb7mIIwGfdiZdlefXMyC+DAFkNloX8IMV7Q==
|
||||
dependencies:
|
||||
"@wharfkit/abicache" "^1.1.1"
|
||||
"@wharfkit/antelope" "^0.7.3"
|
||||
"@wharfkit/signing-request" "^3.0.0"
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/mock-data@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.0.1.tgz#98714437b58f906a1be1755110c7d1e1540edaa7"
|
||||
integrity sha512-9yGS8TiGz06kPmgO6gqpAw2cGik2NJTwBsirMKPWY78/qk9AWb7tMH8sNqQKJozQ+WiXVU3ahYd9t3bLB/f3uQ==
|
||||
dependencies:
|
||||
"@wharfkit/antelope" "^0.7.3"
|
||||
"@wharfkit/session" "^1.0.0-beta9"
|
||||
"@wharfkit/wallet-plugin-privatekey" "^1.0.0-beta1"
|
||||
node-fetch "^2.6.1"
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/session@^1.0.0-beta9":
|
||||
version "1.0.0-beta9"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.0.0-beta9.tgz#854c7b019658328169e0893ab98b6b1efabe0edc"
|
||||
integrity sha512-ixPX0MrE/5vwxYym2j82lVVsEJSaCAHqgjd05AV/Iv+2o9QlTulN1LaAajCKJXzyT1bMwyI2dP+v7+dgKlVtRA==
|
||||
dependencies:
|
||||
"@wharfkit/abicache" "^1.1.1"
|
||||
"@wharfkit/antelope" "^0.7.3"
|
||||
"@wharfkit/common" "^1.1.0"
|
||||
"@wharfkit/signing-request" "^3.0.0"
|
||||
pako "^2.0.4"
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/signing-request@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.0.0.tgz#3464cdc76c0690ab241d805116101e3ed63ba846"
|
||||
integrity sha512-+9UaznhYlZSgdZGG/LF5GkH7P9dCVh+b32cR1PYHKG6KuOsPlLqfv1DuWkqsxQyi3kGT1fXG1i8sl39ItgwLzg==
|
||||
dependencies:
|
||||
"@wharfkit/antelope" "^0.7.3"
|
||||
tslib "^2.0.3"
|
||||
|
||||
"@wharfkit/transact-plugin-resource-provider@^1.0.0-beta1":
|
||||
version "1.0.0-beta1"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/transact-plugin-resource-provider/-/transact-plugin-resource-provider-1.0.0-beta1.tgz#63e998d8e2ce00b44885bfc81cfc8326e9294720"
|
||||
integrity sha512-RhJUzf1q4+q5DgA3j+h82Mm5iTM/Ubglru7v+X/Icq3d0j+JgAbDUG/ARs09TwlT5hXQzRuDR8UIgLkxHkzlEQ==
|
||||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
"@wharfkit/wallet-plugin-privatekey@^1.0.0-beta1":
|
||||
version "1.0.0-beta1"
|
||||
resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-1.0.0-beta1.tgz#1205f311c915a064d3e9c0a7d80c1f475df86ec0"
|
||||
integrity sha512-F6m2t9977OH31SsCRQUZIAHacgQdoqxQw0WxQGsdO/7fXmkLd6DTzRIjHtVQs/4RtHLMMWTs8Zs6akDTo/M9dA==
|
||||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
@@ -1625,16 +1690,16 @@ color-name@~1.1.4:
|
||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
||||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
|
||||
|
||||
commander@^10.0.1:
|
||||
version "10.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
|
||||
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==
|
||||
|
||||
commander@^2.18.0, commander@^2.20.0:
|
||||
version "2.20.3"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
|
||||
|
||||
commander@^9.4.1:
|
||||
version "9.5.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30"
|
||||
integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==
|
||||
|
||||
commondir@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
@@ -1766,14 +1831,6 @@ emoji-regex@^8.0.0:
|
||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
|
||||
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
|
||||
|
||||
eosio-signing-request@^2.5.3:
|
||||
version "2.5.3"
|
||||
resolved "https://registry.yarnpkg.com/eosio-signing-request/-/eosio-signing-request-2.5.3.tgz#4b15bcc67d2814393a83084c45e4473d638b16e1"
|
||||
integrity sha512-jb4cKjQM+NI8+JwtGClYiCDX9sgSeUreRTE7YkIAga0fo21vtLTjTn0ZUH1zyfQU5b4Drdcs/yUMXdPUtqp9bg==
|
||||
dependencies:
|
||||
"@greymass/eosio" "^0.6.0"
|
||||
tslib "^2.0.3"
|
||||
|
||||
es6-error@^4.0.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
|
||||
@@ -3147,10 +3204,10 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
|
||||
semver@^7.3.7, semver@^7.3.8:
|
||||
version "7.3.8"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
|
||||
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
|
||||
semver@^7.3.7, semver@^7.5.0:
|
||||
version "7.5.3"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
|
||||
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
@@ -3389,10 +3446,10 @@ tslib@^1.8.1:
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
|
||||
|
||||
tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.1:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
|
||||
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
|
||||
tslib@^2.0.3, tslib@^2.1.0, tslib@^2.5.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3"
|
||||
integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==
|
||||
|
||||
tsutils@^3.21.0:
|
||||
version "3.21.0"
|
||||
@@ -3656,15 +3713,15 @@ yargs@^15.0.2:
|
||||
y18n "^4.0.0"
|
||||
yargs-parser "^18.1.2"
|
||||
|
||||
yarn-deduplicate@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/yarn-deduplicate/-/yarn-deduplicate-6.0.1.tgz#71d9ee311a10d08edb576a178a5c78fba02f05c2"
|
||||
integrity sha512-wH2+dyLt1cCMx91kmfiB8GhHiZPVmfD9PULoWGryiqgvA+uvcR3k1yaDbB+K/bTx/NBiMhpnSTFdeWM6MqROYQ==
|
||||
yarn-deduplicate@^6.0.2:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/yarn-deduplicate/-/yarn-deduplicate-6.0.2.tgz#63498d2d4c3a8567e992a994ce0ab51aa5681f2e"
|
||||
integrity sha512-Efx4XEj82BgbRJe5gvQbZmEO7pU5DgHgxohYZp98/+GwPqdU90RXtzvHirb7hGlde0sQqk5G3J3Woyjai8hVqA==
|
||||
dependencies:
|
||||
"@yarnpkg/lockfile" "^1.1.0"
|
||||
commander "^9.4.1"
|
||||
semver "^7.3.8"
|
||||
tslib "^2.4.1"
|
||||
commander "^10.0.1"
|
||||
semver "^7.5.0"
|
||||
tslib "^2.5.0"
|
||||
|
||||
yn@3.1.1:
|
||||
version "3.1.1"
|
||||
|
||||
Reference in New Issue
Block a user