Skip to content

Commit

Permalink
Rename everything to Vesper
Browse files Browse the repository at this point in the history
  • Loading branch information
gabmontes committed Nov 3, 2022
1 parent e9b68a4 commit 11649b3
Show file tree
Hide file tree
Showing 23 changed files with 25 additions and 34 deletions.
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ endif

include $(BOLOS_SDK)/Makefile.defines

# EDIT THIS: Put your plugin name
APPNAME = "Boilerplate"
APPNAME = "Vesper"

ifeq ($(ETHEREUM_PLUGIN_SDK),)
ETHEREUM_PLUGIN_SDK=ethereum-plugin-sdk
Expand All @@ -39,9 +38,9 @@ APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# EDIT THIS: Change the name of the gif, and generate you own GIFs!
ifeq ($(TARGET_NAME), TARGET_NANOS)
ICONNAME=icons/nanos_app_boilerplate.gif
ICONNAME=icons/nanos_app_vesper.gif
else
ICONNAME=icons/nanox_app_boilerplate.gif
ICONNAME=icons/nanox_app_vesper.gif
endif

################
Expand Down Expand Up @@ -163,5 +162,4 @@ include $(BOLOS_SDK)/Makefile.rules
dep/%.d: %.c Makefile

listvariants:
# EDIT THIS: replace `boilerplate` by the lowercase name of your plugin
@echo VARIANTS NONE boilerplate
@echo VARIANTS NONE vesper
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# app-plugin-boilerplate
# app-plugin-vesper

This repo contains the Vesper plugin for Ledger Nano S, S Plus and X devices.

Expand Down
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/handle_finalize.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

void handle_finalize(void *parameters) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
Expand Down
4 changes: 2 additions & 2 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

static int find_selector(uint32_t selector, const uint32_t *selectors, size_t n, selector_t *out) {
for (selector_t i = 0; i < n; i++) {
Expand Down Expand Up @@ -36,7 +36,7 @@ void handle_init_contract(void *parameters) {
memset(context, 0, sizeof(*context));

uint32_t selector = U4BE(msg->selector, 0);
if (find_selector(selector, BOILERPLATE_SELECTORS, NUM_SELECTORS, &context->selectorIndex)) {
if (find_selector(selector, VESPER_SELECTORS, NUM_SELECTORS, &context->selectorIndex)) {
msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

// EDIT THIS: Remove this function and write your own handlers!
static void handle_swap_exact_eth_for_tokens(ethPluginProvideParameter_t *msg, context_t *context) {
Expand Down
2 changes: 1 addition & 1 deletion src/handle_provide_token.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

// EDIT THIS: Adapt this function to your needs! Remember, the information for tokens are held in
// `msg->token1` and `msg->token2`. If those pointers are `NULL`, this means the ethereum app didn't
Expand Down
2 changes: 1 addition & 1 deletion src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

// Sets the first screen to display.
void handle_query_contract_id(void *parameters) {
Expand Down
2 changes: 1 addition & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

// EDIT THIS: You need to adapt / remove the static functions (set_send_ui, set_receive_ui ...) to
// match what you wish to display.
Expand Down
9 changes: 4 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
#include "os.h"
#include "cx.h"

#include "boilerplate_plugin.h"
#include "vesper_plugin.h"

// List of selectors supported by this plugin.
// EDIT THIS: Adapt the variable names and change the `0x` values to match your selectors.
static const uint32_t SWAP_EXACT_ETH_FOR_TOKENS_SELECTOR = 0x7ff36ab5;
static const uint32_t BOILERPLATE_DUMMY_SELECTOR_2 = 0x13374242;

// Array of all the different boilerplate selectors. Make sure this follows the same order as the
// enum defined in `boilerplate_plugin.h`
// EDIT THIS: Use the names of the array declared above.
const uint32_t BOILERPLATE_SELECTORS[NUM_SELECTORS] = {
// Array of all the different Vesper selectors. Make sure this follows the same order as the
// enum defined in `vesper_plugin.h`
const uint32_t VESPER_SELECTORS[NUM_SELECTORS] = {
SWAP_EXACT_ETH_FOR_TOKENS_SELECTOR,
BOILERPLATE_DUMMY_SELECTOR_2,
};
Expand Down
6 changes: 2 additions & 4 deletions src/boilerplate_plugin.h → src/vesper_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#define NUM_SELECTORS 2

// Name of the plugin.
// EDIT THIS: Replace with your plugin name.
#define PLUGIN_NAME "Boilerplate"
#define PLUGIN_NAME "Vesper"

// Enumeration of the different selectors possible.
// Should follow the exact same order as the array declared in main.c
Expand All @@ -31,8 +30,7 @@ typedef enum {
UNEXPECTED_PARAMETER,
} parameter;

// EDIT THIS: Rename `BOILERPLATE` to be the same as the one initialized in `main.c`.
extern const uint32_t BOILERPLATE_SELECTORS[NUM_SELECTORS];
extern const uint32_t VESPER_SELECTORS[NUM_SELECTORS];

// Shared global memory with Ethereum app. Must be at most 5 * 32 bytes.
// EDIT THIS: This struct is used by your plugin to save the parameters you parse. You
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"path.1"
],
"method": "swapExactETHForTokens",
"plugin": "Boilerplate"
"plugin": "Vesper"
}
}
}
],
"name": "Boilerplate"
"name": "Vesper"
}
Binary file modified tests/snapshots/nanos_swap_exact_eth_for_tokens/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp_swap_exact_eth_for_tokens/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanox_swap_exact_eth_for_tokens/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions tests/src/generate_plugin_config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// You will need to create a folder with this name, and put in the abis of your contracts in `abis/`.
// You will also need to create a `b2c.json` file that will hold the methodIDs and location of
// the erc20 tokens that should get displayed.
// EDIT THIS: replace with the name of your plugin (lowercase)
const pluginFolder = "boilerplate";
const pluginFolder = "vesper";

function serialize_data(pluginName, contractAddress, selector) {
const len = Buffer.from([pluginName.length]);
Expand Down
3 changes: 1 addition & 2 deletions tests/src/swap_exact_eth_for_tokens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { parseEther, parseUnits} from "ethers/lib/utils";

// EDIT THIS: Replace with your contract address
const contractAddr = "0x7a250d5630b4cf539739df2c5dacb4c659f2488d";
// EDIT THIS: Replace `boilerplate` with your plugin name
const pluginName = "boilerplate";
const pluginName = "vesper";
const testNetwork = "ethereum";
const abi_path = `../networks/${testNetwork}/${pluginName}/abis/` + contractAddr + '.json';
const abi = require(abi_path);
Expand Down
8 changes: 3 additions & 5 deletions tests/src/test.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const nano_models: DeviceModel[] = [
{ name: 'nanox', letter: 'X', path: NANOX_PLUGIN_PATH, eth_path: NANOX_ETH_PATH }
];


const boilerplateJSON = generate_plugin_config();
const vesperJSON = generate_plugin_config();

const SPECULOS_ADDRESS = '0xFE984369CE3919AA7BB4F431082D027B4F8ED70C';
const RANDOM_ADDRESS = '0xaaaabbbbccccddddeeeeffffgggghhhhiiiijjjj'
Expand Down Expand Up @@ -87,8 +86,7 @@ function zemu(device, func) {
let elf_path;
let lib_elf;
elf_path = device.eth_path;
// Edit this: replace `Boilerplate` by your plugin name
lib_elf = { 'Boilerplate': device.path };
lib_elf = { Vesper: device.path };

const sim = new Zemu(elf_path, lib_elf);
try {
Expand All @@ -97,7 +95,7 @@ function zemu(device, func) {
const eth = new Eth(transport);
eth.setLoadConfig({
baseURL: null,
extraPlugins: boilerplateJSON,
extraPlugins: vesperJSON
});
await func(sim, eth);
} finally {
Expand Down

0 comments on commit 11649b3

Please sign in to comment.