Skip to content

Commit 587f661

Browse files
committed
mint action
1 parent 3df4fa4 commit 587f661

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

framelib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
validate_message as validate_message_neynar,
1111
validate_message_or_mock as validate_message_or_mock_neynar
1212
)
13-
from .transaction import transaction
13+
from .transaction import transaction, mint

framelib/transaction.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,14 @@ def transaction(
5151
res = jsonify(tx.model_dump(mode='json', exclude_none=True))
5252
res.status_code = 200
5353
return res
54+
55+
56+
def mint(chain_id: int, contract: str, token_id: int = None) -> str:
57+
if not is_address(contract):
58+
raise ValueError(f'invalid contract address {contract}')
59+
60+
target = f'eip155:{chain_id}:{contract}'
61+
if token_id is not None:
62+
target += f':{token_id}'
63+
64+
return target

test/test_mint.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
test cases for frame minting logic
3+
"""
4+
5+
# lib
6+
import json
7+
import pytest
8+
from flask import Flask
9+
10+
# src
11+
from framelib import mint
12+
13+
14+
class TestTransaction(object):
15+
16+
def test_mint(self):
17+
target = mint(7777777, '0x060f3edd18c47f59bd23d063bbeb9aa4a8fec6df')
18+
assert target == 'eip155:7777777:0x060f3edd18c47f59bd23d063bbeb9aa4a8fec6df'
19+
20+
def test_mint_with_id(self):
21+
target = mint(7777777, '0x060f3edd18c47f59bd23d063bbeb9aa4a8fec6df', token_id=1234)
22+
assert target == 'eip155:7777777:0x060f3edd18c47f59bd23d063bbeb9aa4a8fec6df:1234'

0 commit comments

Comments
 (0)