-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating various bits and using SLIP-0044 coin types Add CI and tool-versions Switch to itemized and add better tests and docs Update Readme with better information Switch to Payment Address Fix test issues Use just `frequency` as the namespace Change name to default token address
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
export const schemas = new Map([]); | ||
import * as defaultTokenAddress from "./defaultTokenAddress.js"; | ||
|
||
export const schemas = new Map([ | ||
[ | ||
"defaultTokenAddress", | ||
{ | ||
model: defaultTokenAddress, | ||
modelType: "AvroBinary", | ||
payloadLocation: "Itemized", | ||
settings: ["SignatureRequired"], | ||
}, | ||
], | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 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: "DefaultTokenAddress", | ||
namespace: "frequency", | ||
fields: [ | ||
{ | ||
name: "token_slip_0044", | ||
type: "int", | ||
doc: "Network for this token address using SLIP-0044 registered coin type integers", | ||
}, | ||
{ | ||
name: "address", | ||
type: "string", | ||
doc: "The address as a string encoded in standard way for the given coin type", | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expect, test, it } from "vitest"; | ||
import avro from "avsc"; | ||
import defaultTokenAddress from "./defaultTokenAddress.js"; | ||
|
||
test("Token Addresses Schema is Avro", () => { | ||
const schema = avro.Type.forSchema(defaultTokenAddress); | ||
expect(schema).toBeDefined(); | ||
}); | ||
|
||
test("Token Addresses Schema can take the correct data", () => { | ||
const schema = avro.Type.forSchema(defaultTokenAddress); | ||
const dot = schema.toBuffer({ | ||
token_slip_0044: 354, | ||
address: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
}); | ||
expect(dot).toBeDefined(); | ||
expect(schema.fromBuffer(dot).token_slip_0044).toBe(354); | ||
|
||
const btc = schema.toBuffer({ | ||
token_slip_0044: 0, | ||
address: "34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo", | ||
}); | ||
expect(btc).toBeDefined(); | ||
expect(schema.fromBuffer(btc).token_slip_0044).toBe(0); | ||
}); |