Skip to content

Commit

Permalink
Change name to default token address
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Sep 20, 2024
1 parent 2d66505 commit bc01d94
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ Some generic schemas for improving the usability of Frequency

## Schemas

### Payment Addresses
### Default Token Address

- Goal: Allow MSAs to list their payment addresses, both from Frequency and other chains
- Goal: Allow MSAs to list their default token sending and receiving addresses, both from Frequency and other chains
- Payload Location Options
- Itemized: Each piece of data is atomic
- Signature Required: Creating or removing connecting addresses should require user sign-off

#### Data

- Wallet Address: String form for the specific chain
- Coin Type: SLIP-0044 Chain Identifier
- Address: String form of the token address for the specific chain
- Token: SLIP-0044 Chain Identifier

#### References

Expand Down Expand Up @@ -52,9 +52,9 @@ DEPLOY_SCHEMA_ACCOUNT_URI="//Bob" DEPLOY_SCHEMA_ENDPOINT_URL="ws://127.0.0.1:994

### To register a single schema

e.g. To register the "walletAddresses" schema
e.g. To register the "defaultTokenAddress" schema

npm run deploy walletAddresses
npm run deploy defaultTokenAddress

**Note:** Requires a sudo key if deploying to a testnet.
Mainnet will use the proposal system (`proposeToCreateSchema`).
Expand Down
6 changes: 3 additions & 3 deletions schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as paymentAddress from "./paymentAddress.js";
import * as defaultTokenAddress from "./defaultTokenAddress.js";

export const schemas = new Map([
[
"paymentAddress",
"defaultTokenAddress",
{
model: paymentAddress,
model: defaultTokenAddress,
modelType: "AvroBinary",
payloadLocation: "Itemized",
settings: ["SignatureRequired"],
Expand Down
8 changes: 4 additions & 4 deletions schemas/paymentAddress.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* Payment Address is a way to record a payment addresses for an MSA
* Token Address is a way to record a token sending and receiving addresses for an MSA
* Should be stored using Itemized and Signature Required
* SLIP-0044 Standard: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
*/
export default {
type: "record",
name: "PaymentAddress",
name: "DefaultTokenAddress",
namespace: "frequency",
fields: [
{
name: "coin_type_slip_0044",
name: "token_slip_0044",
type: "int",
doc: "Coin/Network using SLIP-0044 registered coin type integers",
doc: "Network for this token address using SLIP-0044 registered coin type integers",
},
{
name: "address",
Expand Down
18 changes: 9 additions & 9 deletions schemas/paymentAddress.spec.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { expect, test, it } from "vitest";
import avro from "avsc";
import paymentAddresses from "./paymentAddress.js";
import defaultTokenAddress from "./defaultTokenAddress.js";

test("Payment Addresses Schema is Avro", () => {
const schema = avro.Type.forSchema(paymentAddresses);
test("Token Addresses Schema is Avro", () => {
const schema = avro.Type.forSchema(defaultTokenAddress);
expect(schema).toBeDefined();
});

test("Payment Addresses Schema can take the correct data", () => {
const schema = avro.Type.forSchema(paymentAddresses);
test("Token Addresses Schema can take the correct data", () => {
const schema = avro.Type.forSchema(defaultTokenAddress);
const dot = schema.toBuffer({
coin_type_slip_0044: 354,
token_slip_0044: 354,
address: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
});
expect(dot).toBeDefined();
expect(schema.fromBuffer(dot).coin_type_slip_0044).toBe(354);
expect(schema.fromBuffer(dot).token_slip_0044).toBe(354);

const btc = schema.toBuffer({
coin_type_slip_0044: 0,
token_slip_0044: 0,
address: "34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo",
});
expect(btc).toBeDefined();
expect(schema.fromBuffer(btc).coin_type_slip_0044).toBe(0);
expect(schema.fromBuffer(btc).token_slip_0044).toBe(0);
});

0 comments on commit bc01d94

Please sign in to comment.