Initial commit

This commit is contained in:
Aaron Cox
2024-06-15 20:55:20 -07:00
committed by GitHub
commit 5a13e4ae43
19 changed files with 3482 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
+27
View File
@@ -0,0 +1,27 @@
{
"root": true,
"ignorePatterns": ["lib/*", "node_modules/**"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": "warn",
"no-console": "warn",
"sort-imports": [
"warn",
{
"ignoreCase": true,
"ignoreDeclarationSort": true
}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-function": "warn",
"no-inner-declarations": "off"
}
}
+1
View File
@@ -0,0 +1 @@
custom: 'https://greymass.com/support-us'
+23
View File
@@ -0,0 +1,23 @@
name: Tests
on: push
jobs:
test-node-js:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
name: Node.js v${{ matrix.node-version }}
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: make node_modules
- name: Run checks
run: make check
- name: Run tests
run: make ci-test
+2
View File
@@ -0,0 +1,2 @@
node_modules/
lib/
+8
View File
@@ -0,0 +1,8 @@
arrowParens: "always"
bracketSpacing: false
endOfLine: "lf"
printWidth: 100
semi: false
singleQuote: true
tabWidth: 4
trailingComma: "es5"
+29
View File
@@ -0,0 +1,29 @@
Copyright (c) 2023 Greymass Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistribution of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistribution in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
+81
View File
@@ -0,0 +1,81 @@
SHELL := /bin/bash
SRC_FILES := $(shell find src -name '*.ts')
TEST_FILES := $(shell find test/tests -name '*.ts')
BIN := ./node_modules/.bin
MOCHA_OPTS := -u tdd -r ts-node/register -r tsconfig-paths/register --extension ts
NYC_OPTS := --temp-dir build/nyc_output --report-dir build/coverage
lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
@${BIN}/rollup -c && touch lib
.PHONY: test
test: node_modules
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
${BIN}/mocha ${MOCHA_OPTS} ${TEST_FILES} --grep '$(grep)'
build/coverage: ${SRC_FILES} ${TEST_FILES} node_modules
@TS_NODE_PROJECT='./test/tsconfig.json' \
${BIN}/nyc ${NYC_OPTS} --reporter=html \
${BIN}/mocha ${MOCHA_OPTS} -R nyan ${TEST_FILES}
.PHONY: coverage
coverage: build/coverage
@open build/coverage/index.html
.PHONY: ci-test
ci-test: node_modules
@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"
.PHONY: format
format: node_modules
@${BIN}/eslint src --ext .ts --fix
.PHONY: publish
publish: | distclean node_modules
@git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1)
@git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1)
@yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s"
@yarn publish && git push && git push --tags
.PHONY: docs
docs: build/docs
@open build/docs/index.html
build/docs: $(SRC_FILES) node_modules
@${BIN}/typedoc --out build/docs \
--excludeInternal --excludePrivate --excludeProtected \
--includeVersion --hideGenerator --readme none \
src/index.ts
build/pages: build/docs test/browser.html
@mkdir -p build/pages
@cp -r build/docs/* build/pages/
@cp test/browser.html build/pages/tests.html
.PHONY: deploy-pages
deploy-pages: | clean build/pages node_modules
@${BIN}/gh-pages -d build/pages
test/browser.html: $(SRC_FILES) $(TEST_FILES) test/rollup.config.js node_modules
@${BIN}/rollup -c test/rollup.config.js
.PHONY: browser-test
browser-test: test/browser.html
@open test/browser.html
node_modules:
yarn install --non-interactive --frozen-lockfile --ignore-scripts
.PHONY: clean
clean:
rm -rf lib/ build/ test/browser.html
.PHONY: distclean
distclean: clean
rm -rf node_modules/
+20
View File
@@ -0,0 +1,20 @@
# @wharfkit/wallet-plugin-template
A template to create a `WalletPlugin` for use within the `@wharfkit/session` library.
## Usage
- [Use this as a template.](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
- Write your wallet plugin's logic.
- Publish it on Github or npmjs.com
- Include it in your project and use it.
## Developing
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.
Clone the repository and run `make` to checkout all dependencies and build the project. See the [Makefile](./Makefile) for other useful targets. Before submitting a pull request make sure to run `make lint`.
---
Made with ☕️ & ❤️ by [Greymass](https://greymass.com), if you find this useful please consider [supporting us](https://greymass.com/support-us).
+57
View File
@@ -0,0 +1,57 @@
{
"name": "@wharfkit/wallet-plugin-template",
"description": "A template to create wallet plugins for use with @wharfkit/session.",
"version": "1.1.0",
"homepage": "https://github.com/wharfkit/wallet-plugin-template",
"license": "BSD-3-Clause",
"main": "lib/wallet-plugin-template.js",
"module": "lib/wallet-plugin-template.m.js",
"types": "lib/wallet-plugin-template.d.ts",
"sideEffects": false,
"files": [
"lib/*",
"src/*"
],
"scripts": {
"prepare": "make"
},
"dependencies": {
"tslib": "^2.1.0"
},
"peerDependencies": {
"@wharfkit/session": "^1.1.0"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.4",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^14.1.0",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@rollup/plugin-virtual": "^2.0.3",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.0.0",
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"@wharfkit/mock-data": "^1.2.0",
"@wharfkit/session": "^1.1.0-rcfinal",
"chai": "^4.3.4",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^4.0.0",
"gh-pages": "^4.0.0",
"mocha": "^10.0.0",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"rollup": "^2.70.2",
"rollup-plugin-dts": "^4.2.1",
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.1",
"typedoc": "^0.23.14",
"typescript": "^4.1.2",
"yarn-deduplicate": "^6.0.1"
}
}
+51
View File
@@ -0,0 +1,51 @@
import fs from 'fs'
import dts from 'rollup-plugin-dts'
import typescript from '@rollup/plugin-typescript'
import pkg from './package.json'
const name = pkg.name
const license = fs.readFileSync('LICENSE').toString('utf-8').trim()
const banner = `
/**
* ${name} v${pkg.version}
* ${pkg.homepage}
*
* @license
* ${license.replace(/\n/g, '\n * ')}
*/
`.trim()
const external = Object.keys(pkg.peerDependencies)
/** @type {import('rollup').RollupOptions} */
export default [
{
input: 'src/index.ts',
output: {
banner,
file: pkg.main,
format: 'cjs',
sourcemap: true,
exports: 'named',
},
plugins: [typescript({target: 'es6'})],
external,
},
{
input: 'src/index.ts',
output: {
banner,
file: pkg.module,
format: 'esm',
sourcemap: true,
},
plugins: [typescript({target: 'es2020'})],
external,
},
{
input: 'src/index.ts',
output: {banner, file: pkg.types, format: 'esm'},
plugins: [dts()],
},
]
+87
View File
@@ -0,0 +1,87 @@
import {
AbstractWalletPlugin,
Checksum256,
LoginContext,
PermissionLevel,
ResolvedSigningRequest,
Signature,
TransactContext,
WalletPlugin,
WalletPluginConfig,
WalletPluginLoginResponse,
WalletPluginMetadata,
WalletPluginSignResponse,
} from '@wharfkit/session'
export class WalletPluginTEMPLATE extends AbstractWalletPlugin implements WalletPlugin {
/**
* The logic configuration for the wallet plugin.
*/
readonly config: WalletPluginConfig = {
// Should the user interface display a chain selector?
requiresChainSelect: true,
// Should the user interface display a permission selector?
requiresPermissionSelect: false,
// Optionally specify if this plugin only works with specific blockchains.
// supportedChains: ['73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d']
}
/**
* The metadata for the wallet plugin to be displayed in the user interface.
*/
readonly metadata: WalletPluginMetadata = WalletPluginMetadata.from({
name: 'Wallet Plugin Template',
description: 'A template that can be used to build wallet plugins!',
logo: 'base_64_encoded_image',
homepage: 'https://someplace.com',
download: 'https://someplace.com/download',
})
/**
* A unique string identifier for this wallet plugin.
*
* It's recommended this is all lower case, no spaces, and only URL-friendly special characters (dashes, underscores, etc)
*/
get id(): string {
return 'wallet-plugin-template'
}
/**
* Performs the wallet logic required to login and return the chain and permission level to use.
*
* @param options WalletPluginLoginOptions
* @returns Promise<WalletPluginLoginResponse>
*/
// TODO: Remove these eslint rule modifiers when you are implementing this method.
/* eslint-disable @typescript-eslint/no-unused-vars */
async login(context: LoginContext): Promise<WalletPluginLoginResponse> {
// Example response...
return {
chain: Checksum256.from(
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
),
permissionLevel: PermissionLevel.from('wharfkit1111@test'),
}
}
/**
* Performs the wallet logic required to sign a transaction and return the signature.
*
* @param chain ChainDefinition
* @param resolved ResolvedSigningRequest
* @returns Promise<Signature>
*/
// TODO: Remove these eslint rule modifiers when you are implementing this method.
/* eslint-disable @typescript-eslint/no-unused-vars */
async sign(
resolved: ResolvedSigningRequest,
context: TransactContext
): Promise<WalletPluginSignResponse> {
// Example response...
return {
signatures: [
Signature.from(
'SIG_K1_KfqBXGdSRnVgZbAXyL9hEYbAvrZjcaxUCenD7Z3aX6yzf6MEyc4Cy3ywToD4j3SKkzSg7L1uvRUirEPHwAwrbg5c9z27Z3'
),
],
}
}
}
@@ -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,32 @@
{
"request": {
"path": "https://jungle4.greymass.com/v1/chain/get_info",
"params": {
"method": "GET"
}
},
"status": 200,
"json": {
"server_version": "905c5cc9",
"chain_id": "73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d",
"head_block_num": 107760337,
"last_irreversible_block_num": 107760010,
"last_irreversible_block_id": "066c498a86f39c797299bab0d7e6b1b176105c83cf5746dab87f6001fbf9c292",
"head_block_id": "066c4ad138a5fe1d1710e90ef5dabeebb44a68e8e671dfa56cfa0f90a755996c",
"head_block_time": "2023-11-10T17:30:55.000",
"head_block_producer": "ivote4eosusa",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 200000,
"block_net_limit": 1048576,
"server_version_string": "v3.1.3",
"fork_db_head_block_num": 107760337,
"fork_db_head_block_id": "066c4ad138a5fe1d1710e90ef5dabeebb44a68e8e671dfa56cfa0f90a755996c",
"server_full_version_string": "v3.1.3-905c5cc900b4e88aed4ab6912009127bf9f4f140",
"total_cpu_weight": "120613298869319",
"total_net_weight": "117529300091371",
"earliest_available_block_num": 107585477,
"last_irreversible_block_time": "2023-11-10T17:28:11.500"
},
"text": "{\"server_version\":\"905c5cc9\",\"chain_id\":\"73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d\",\"head_block_num\":107760337,\"last_irreversible_block_num\":107760010,\"last_irreversible_block_id\":\"066c498a86f39c797299bab0d7e6b1b176105c83cf5746dab87f6001fbf9c292\",\"head_block_id\":\"066c4ad138a5fe1d1710e90ef5dabeebb44a68e8e671dfa56cfa0f90a755996c\",\"head_block_time\":\"2023-11-10T17:30:55.000\",\"head_block_producer\":\"ivote4eosusa\",\"virtual_block_cpu_limit\":200000000,\"virtual_block_net_limit\":1048576000,\"block_cpu_limit\":200000,\"block_net_limit\":1048576,\"server_version_string\":\"v3.1.3\",\"fork_db_head_block_num\":107760337,\"fork_db_head_block_id\":\"066c4ad138a5fe1d1710e90ef5dabeebb44a68e8e671dfa56cfa0f90a755996c\",\"server_full_version_string\":\"v3.1.3-905c5cc900b4e88aed4ab6912009127bf9f4f140\",\"total_cpu_weight\":\"120613298869319\",\"total_net_weight\":\"117529300091371\",\"earliest_available_block_num\":107585477,\"last_irreversible_block_time\":\"2023-11-10T17:28:11.500\"}"
}
+111
View File
@@ -0,0 +1,111 @@
/* eslint-disable no-undef */
import fs from 'fs'
import path from 'path'
import {terser} from 'rollup-plugin-terser'
import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import virtual from '@rollup/plugin-virtual'
const mockData = Object.fromEntries(
fs
.readdirSync(path.join(__dirname, 'data'))
.map((f) => path.join(__dirname, 'data', f))
.map((f) => [path.basename(f), JSON.parse(fs.readFileSync(f))])
)
const testFiles = fs
.readdirSync(path.join(__dirname, 'tests'))
.filter((f) => f.match(/\.ts$/))
.map((f) => path.join(__dirname, 'tests', f))
.sort()
const template = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('tdd');
mocha.checkLeaks();
</script>
<script>%%tests%%</script>
<script class="mocha-exec">
mocha.run();
</script>
</body>
</html>
`
function inline() {
return {
name: 'Inliner',
generateBundle(opts, bundle) {
const file = path.basename(opts.file)
const output = bundle[file]
delete bundle[file]
const code = `${output.code}`
this.emitFile({
type: 'asset',
fileName: file,
source: template.replace('%%tests%%', code),
})
},
}
}
/** @type {import('rollup').RollupOptions} */
export default [
{
input: 'tests.ts',
output: {
file: 'build/browser.html',
format: 'iife',
sourcemap: true,
globals: {
chai: 'chai',
mocha: 'mocha',
util: 'undefined',
crypto: 'undefined',
},
},
external: ['chai', 'mocha', 'crypto', 'util'],
plugins: [
virtual({
'tests.ts': testFiles.map((f) => `import '${f.slice(0, -3)}'`).join('\n'),
}),
alias({
entries: [
{find: '$lib', replacement: path.join(__dirname, '..', 'lib/session.m.js')},
{find: './utils/mock-provider', replacement: './utils/browser-provider.ts'},
],
}),
typescript({target: 'es6', module: 'esnext', tsconfig: './test/tsconfig.json'}),
replace({'global.MOCK_DATA': JSON.stringify(mockData), preventAssignment: true}),
resolve({browser: true}),
commonjs(),
json(),
terser({
mangle: false,
format: {
beautify: true,
},
compress: false,
}),
inline(),
],
},
]
+51
View File
@@ -0,0 +1,51 @@
import {assert} from 'chai'
import {PermissionLevel, SessionKit} from '@wharfkit/session'
import {
mockChainDefinition,
mockPermissionLevel,
mockSessionKitArgs,
mockSessionKitOptions,
} from '@wharfkit/mock-data'
import {WalletPluginTEMPLATE} from '$lib'
suite('wallet plugin', function () {
test('login and sign', async function () {
const kit = new SessionKit(
{
...mockSessionKitArgs,
walletPlugins: [new WalletPluginTEMPLATE()],
},
mockSessionKitOptions
)
const {session} = await kit.login({
chain: mockChainDefinition.id,
permissionLevel: mockPermissionLevel,
})
assert.isTrue(session.chain.equals(mockChainDefinition))
assert.isTrue(session.actor.equals(PermissionLevel.from(mockPermissionLevel).actor))
assert.isTrue(
session.permission.equals(PermissionLevel.from(mockPermissionLevel).permission)
)
const result = await session.transact(
{
action: {
authorization: [PermissionLevel.from(mockPermissionLevel)],
account: 'eosio.token',
name: 'transfer',
data: {
from: PermissionLevel.from(mockPermissionLevel).actor,
to: 'wharfkittest',
quantity: '0.0001 EOS',
memo: 'wharfkit/session wallet plugin template',
},
},
},
{
broadcast: false,
}
)
assert.isTrue(result.signer.equals(mockPermissionLevel))
assert.equal(result.signatures.length, 1)
})
})
+17
View File
@@ -0,0 +1,17 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"isolatedModules": false,
"resolveJsonModule": true,
"module": "commonjs",
"target": "es6",
"types": ["mocha", "node"],
"baseUrl": "..",
"paths": {
"$lib": ["src"],
"$test": ["test"],
"$test/*": ["test/*"]
}
},
"include": ["*.ts", "**/*.ts"]
}
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": true,
"isolatedModules": true,
"lib": ["dom", "es2020"],
"module": "es2020",
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": true,
"strict": true,
"target": "es2020"
},
"include": ["src/**/*"]
}
+2839
View File
File diff suppressed because it is too large Load Diff