Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
add newaddress
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Dec 30, 2023
1 parent c08a70a commit 42de9eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ord.pomelo.contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ title: load
summary: load assets from contract
icon: https://gateway.pinata.cloud/ipfs/QmNbkDh7ZSkRf7j1peg9YnDoBnJbVg5TMdRfVGYV3hxhhD#b74cf8b3d884f42fffea4bfe7070b3871e1845805c57973a48324af1228ad9cc
---


<h1 class="contract">newaddress</h1>

---
spec_version: "0.2.0"
title: newaddress
summary: New bech32 Bitcoin address
icon: https://gateway.pinata.cloud/ipfs/QmNbkDh7ZSkRf7j1peg9YnDoBnJbVg5TMdRfVGYV3hxhhD#b74cf8b3d884f42fffea4bfe7070b3871e1845805c57973a48324af1228ad9cc
---
15 changes: 15 additions & 0 deletions ord.pomelo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

#include "ord.pomelo.hpp"

[[eosio::action]]
void ord::newaddress(const name from, const uint64_t asset_id, const string bech32_bitcoin_address)
{
require_auth(from);

check_bech32_bitcoin_address(bech32_bitcoin_address);
ord::ords_table _ords( get_self(), get_self().value );
auto ord = _ords.get(asset_id, "Asset ID not found");
check(ord.from == from, "Cannot change NFT asset address unless owner");
check(ord.bech32_bitcoin_address != bech32_bitcoin_address, "New address is the same as the old address");
_ords.modify(ord, same_payer, [&](auto &row) {
row.bech32_bitcoin_address = bech32_bitcoin_address;
});
}

[[eosio::action]]
void ord::init( const time_point_sec start_time, const int32_t template_id, const uint8_t max_per_account )
{
Expand Down
3 changes: 3 additions & 0 deletions ord.pomelo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class [[eosio::contract("ord.pomelo")]] ord : public eosio::contract {
[[eosio::action]]
void validate( const string bech32_bitcoin_address );

[[eosio::action]]
void newaddress(const name from, const uint64_t asset_id, const string bech32_bitcoin_address);

[[eosio::action]]
void receipt( const name from, const uint64_t asset_id, const time_point_sec transfer_time, const string bech32_bitcoin_address ) {
require_auth(get_self());
Expand Down

0 comments on commit 42de9eb

Please sign in to comment.