Skip to content

Commit

Permalink
Added Resource Provider plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Oct 1, 2024
1 parent 1354503 commit 2385b9c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@wharfkit/resources": "^1.2.3",
"@wharfkit/roborovski": "^1.0.0",
"@wharfkit/session": "^1.4.0",
"@wharfkit/transact-plugin-resource-provider": "^1.1.1",
"@wharfkit/wallet-plugin-anchor": "^1.4.0",
"@wharfkit/wallet-plugin-metamask": "1.0.0-rc8",
"@wharfkit/wallet-plugin-privatekey": "^1.1.0",
Expand Down
32 changes: 18 additions & 14 deletions src/lib/state/client/wharf.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type SerializedSession,
type TransactArgs,
type TransactOptions,
type TransactPlugin,
type TransactResult,
type WalletPlugin,
Session,
Expand All @@ -22,11 +23,13 @@ import { WalletPluginPrivateKey } from '@wharfkit/wallet-plugin-privatekey';
import { WalletPluginWombat } from '@wharfkit/wallet-plugin-wombat';
import { WalletPluginScatter } from '@wharfkit/wallet-plugin-scatter';
import { WalletPluginTokenPocket } from '@wharfkit/wallet-plugin-tokenpocket';
import { TransactPluginResourceProvider } from '@wharfkit/transact-plugin-resource-provider';

import { AccountCreationPluginMetamask } from '@wharfkit/account-creation-plugin-metamask';
import { AccountCreationPluginGreymass } from '@wharfkit/account-creation-plugin-greymass';

import { TransactPluginStatusEmitter } from '$lib/wharf/plugins/status';

import {
type QueuedTransaction,
StatusType,
Expand All @@ -50,6 +53,11 @@ const accountCreationPlugins: AccountCreationPlugin[] = [
new AccountCreationPluginGreymass()
];

const transactPlugins: TransactPlugin[] = [
new TransactPluginStatusEmitter(),
new TransactPluginResourceProvider()
];

// If a local key is provided, add the private key wallet
if (PUBLIC_LOCAL_SIGNER) {
walletPlugins.unshift(new WalletPluginPrivateKey(PUBLIC_LOCAL_SIGNER));
Expand Down Expand Up @@ -80,7 +88,8 @@ export class WharfState {
walletPlugins
},
{
accountCreationPlugins
accountCreationPlugins,
transactPlugins
}
);
$effect(() => {
Expand Down Expand Up @@ -173,19 +182,14 @@ export class WharfState {
options
};

const result = await this.session
.transact(args, {
...options,
transactPlugins: [new TransactPluginStatusEmitter()]
})
.catch((e: Error) => {
transaction.status = StatusType.ERROR;
transaction.error = String(e);
queueTransaction(transaction);
const { id } = sendErrorToast(transaction);
transaction.toastId = id;
throw e;
});
const result = await this.session.transact(args).catch((e: Error) => {
transaction.status = StatusType.ERROR;
transaction.error = String(e);
queueTransaction(transaction);
const { id } = sendErrorToast(transaction);
transaction.toastId = id;
throw e;
});

if (!result.resolved || !result.response) {
transaction.status = StatusType.ERROR;
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: 48C7A666F9C95E3C-fcd1ec80bbafc1de-F0A73B2FA43BB259-06aaab72026e0abd
# bun ./bun.lockb --hash: A4F171440C5B490A-21903874e3f4a24d-976E6F38189A24BC-b4d5738a4b21bcd1


"@alloc/quick-lru@^5.2.0":
Expand Down Expand Up @@ -1524,6 +1524,13 @@
bn.js "^4.11.9"
tslib "^2.1.0"

"@wharfkit/transact-plugin-resource-provider@^1.1.1":
version "1.1.1"
resolved "https://registry.npmjs.org/@wharfkit/transact-plugin-resource-provider/-/transact-plugin-resource-provider-1.1.1.tgz"
integrity sha512-y1VyXPyiO2ihPBej1FKhkuVh3UN5li+Bvjp5CIeNkL6XtmYw4Vdax9hO31qem3zs84YE+vB8WvogoSSICAU10Q==
dependencies:
tslib "^2.1.0"

"@wharfkit/wallet-plugin-anchor@^1.4.0":
version "1.4.0"
resolved "https://registry.npmjs.org/@wharfkit/wallet-plugin-anchor/-/wallet-plugin-anchor-1.4.0.tgz"
Expand Down

0 comments on commit 2385b9c

Please sign in to comment.