Skip to content

Commit

Permalink
fix CI and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Sep 19, 2024
1 parent 2e6c5c6 commit f2393aa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 31 deletions.
1 change: 0 additions & 1 deletion packages/examples/packages/send-flow/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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/),
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/send-flow/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "0z0EeOogIlK+zdR4HsfZW4AznqBlTrLc1Zxxe0eQZII=",
"shasum": "cw0v0wyDRw/bPiyDVlfHhJS1pnKkCul3eh7VheiaHIM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
26 changes: 26 additions & 0 deletions packages/examples/packages/send-flow/src/data.ts
Original file line number Diff line number Diff line change
@@ -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<string, Account> = {
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);
3 changes: 0 additions & 3 deletions packages/examples/packages/send-flow/src/images/btc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions packages/examples/packages/send-flow/src/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { expect } from '@jest/globals';
import { installSnap } from '@metamask/snaps-jest';

describe('onRpcRequest', () => {
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');
});
});
28 changes: 2 additions & 26 deletions packages/examples/packages/send-flow/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Account> = {
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:
Expand Down

0 comments on commit f2393aa

Please sign in to comment.