Skip to content

Commit

Permalink
Update SDK encoding/decoding for Cadence 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Apr 30, 2024
1 parent 11b8f9d commit e926f27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
24 changes: 4 additions & 20 deletions packages/sdk/src/decode/decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,9 @@ const decodeType = async type => {
return type.staticType
}

const decodePath = async path => {
return {
domain: path.domain,
identifier: path.identifier,
}
}

const decodeCapability = async cap => {
return {
path: cap.path,
address: cap.address,
borrowType: cap.borrowType,
}
}

const decodeOptional = async (optional, decoders, stack) =>
optional ? await recurseDecode(optional, decoders, stack) : null

const decodeReference = async v => ({address: v.address, type: v.type})

const decodeArray = async (array, decoders, stack) =>
await Promise.all(
array.map(
Expand Down Expand Up @@ -102,16 +85,17 @@ const defaultDecoders = {
Address: decodeImplicit,
Void: decodeVoid,
Optional: decodeOptional,
Reference: decodeReference,
Reference: decodeImplicit,
Array: decodeArray,
Dictionary: decodeDictionary,
Event: decodeComposite,
Resource: decodeComposite,
Struct: decodeComposite,
Enum: decodeComposite,
Type: decodeType,
Path: decodePath,
Capability: decodeCapability,
Path: decodeImplicit,
Capability: decodeImplicit,
InclusiveRange: decodeImplicit,
}

const decoderLookup = (decoders, lookup) => {
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ export const Optional = <
v => v
)

// todo: this doesn't look right
export const Reference = typedef(
"Reference",
(v: ReferenceValue) => {
Expand Down

0 comments on commit e926f27

Please sign in to comment.