diff --git a/packages/examples/packages/send-flow/CHANGELOG.md b/packages/examples/packages/send-flow/CHANGELOG.md index 720e00537e..aa399df1be 100644 --- a/packages/examples/packages/send-flow/CHANGELOG.md +++ b/packages/examples/packages/send-flow/CHANGELOG.md @@ -1,5 +1,4 @@ # Changelog - All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), diff --git a/packages/examples/packages/send-flow/snap.manifest.json b/packages/examples/packages/send-flow/snap.manifest.json index 0396cf51f1..59d3cbf1c3 100644 --- a/packages/examples/packages/send-flow/snap.manifest.json +++ b/packages/examples/packages/send-flow/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "0z0EeOogIlK+zdR4HsfZW4AznqBlTrLc1Zxxe0eQZII=", + "shasum": "cw0v0wyDRw/bPiyDVlfHhJS1pnKkCul3eh7VheiaHIM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/send-flow/src/data.ts b/packages/examples/packages/send-flow/src/data.ts new file mode 100644 index 0000000000..4b821fb503 --- /dev/null +++ b/packages/examples/packages/send-flow/src/data.ts @@ -0,0 +1,26 @@ +import jazzicon1 from './images/jazzicon1.svg'; +import jazzicon2 from './images/jazzicon2.svg'; +import type { Account } from './types'; + +/** + * Example accounts data. + */ +export const accounts: Record = { + bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh: { + name: 'My Bitcoin Account', + address: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', + balance: { amount: 1.8, fiat: 92000 }, + icon: jazzicon1, + }, + bc1pmpg8yzpty4xgp497qdydkcqt90zz68n48wzwm757vk8nrlkat99q272xm3: { + name: 'Savings Account', + address: 'bc1pmpg8yzpty4xgp497qdydkcqt90zz68n48wzwm757vk8nrlkat99q272xm3', + balance: { amount: 2.5, fiat: 150000 }, + icon: jazzicon2, + }, +}; + +/** + * Example accounts data as an array. + */ +export const accountsArray = Object.values(accounts); diff --git a/packages/examples/packages/send-flow/src/images/btc.svg b/packages/examples/packages/send-flow/src/images/btc.svg index 2b75c99bc2..f5889766e2 100644 --- a/packages/examples/packages/send-flow/src/images/btc.svg +++ b/packages/examples/packages/send-flow/src/images/btc.svg @@ -1,6 +1,3 @@ - - - { + it('throws an error if the requested method does not exist', async () => { + const { request } = await installSnap(); + + const response = await request({ + method: 'foo', + }); + + expect(response).toRespondWithError({ + code: -32601, + message: 'The method does not exist / is not available.', + stack: expect.any(String), + data: { + method: 'foo', + cause: null, + }, + }); + }); + + describe('display', () => { + it.todo('shows a custom dialog with the SendFlow interface'); + }); +}); diff --git a/packages/examples/packages/send-flow/src/index.tsx b/packages/examples/packages/send-flow/src/index.tsx index 5d6f607b4c..6334ab90a8 100644 --- a/packages/examples/packages/send-flow/src/index.tsx +++ b/packages/examples/packages/send-flow/src/index.tsx @@ -9,34 +9,10 @@ import { } from '@metamask/snaps-sdk'; import { SendFlow } from './components'; -import jazzicon1 from './images/jazzicon1.svg'; -import jazzicon2 from './images/jazzicon2.svg'; -import type { Account, SendFormState, SendFlowContext } from './types'; +import { accountsArray, accounts } from './data'; +import type { SendFormState, SendFlowContext } from './types'; import { formValidation, generateSendFlow } from './utils'; -/** - * Example accounts data. - */ -const accounts: Record = { - bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh: { - name: 'My Bitcoin Account', - address: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', - balance: { amount: 1.8, fiat: 92000 }, - icon: jazzicon1, - }, - bc1pmpg8yzpty4xgp497qdydkcqt90zz68n48wzwm757vk8nrlkat99q272xm3: { - name: 'Savings Account', - address: 'bc1pmpg8yzpty4xgp497qdydkcqt90zz68n48wzwm757vk8nrlkat99q272xm3', - balance: { amount: 2.5, fiat: 150000 }, - icon: jazzicon2, - }, -}; - -/** - * Example accounts data as an array. - */ -const accountsArray = Object.values(accounts); - /** * Handle incoming JSON-RPC requests from the dapp, sent through the * `wallet_invokeSnap` method. This handler handles one method: