Skip to content

Commit

Permalink
fix: message tag to 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Apr 11, 2023
1 parent e7e0f64 commit b79034b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Receipt from './receipt.js'
import * as Schema from './schema.js'

export const MessageSchema = Schema.variant({
'ucanto/message@0.6.0': Schema.struct({
'ucanto/message@7.0.0': Schema.struct({
execute: Schema.link().array().optional(),
delegate: Schema.dictionary({
key: Schema.string(),
Expand Down Expand Up @@ -45,7 +45,7 @@ export const view = ({ root, store }, fallback) => {
const data = DAG.CBOR.decode(block.bytes)
const [branch, value] = MessageSchema.match(data, fallback)
switch (branch) {
case 'ucanto/message@0.6.0':
case 'ucanto/message@7.0.0':
return new Message({ root: { ...block, data }, store })
default:
return value
Expand Down Expand Up @@ -89,7 +89,7 @@ class MessageBuilder {
const root = await DAG.writeInto(
/** @type {API.AgentMessageModel<{ In: API.InferInvocations<I>, Out: R }>} */
({
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
...executeField,
...receiptsField,
},
Expand Down Expand Up @@ -196,7 +196,7 @@ class Message {
* @returns {API.Receipt|E}
*/
get(link, fallback) {
const receipts = this.root.data['ucanto/message@0.6.0'].report || {}
const receipts = this.root.data['ucanto/message@7.0.0'].report || {}
const receipt = receipts[`${link}`]
if (receipt) {
return Receipt.view({ root: receipt, blocks: this.store })
Expand All @@ -208,7 +208,7 @@ class Message {
}

get invocationLinks() {
return this.root.data['ucanto/message@0.6.0'].execute || []
return this.root.data['ucanto/message@7.0.0'].execute || []
}

get invocations() {
Expand All @@ -226,7 +226,7 @@ class Message {
let receipts = this._receipts
if (!receipts) {
receipts = new Map()
const report = this.root.data['ucanto/message@0.6.0'].report || {}
const report = this.root.data['ucanto/message@7.0.0'].report || {}
for (const [key, link] of Object.entries(report)) {
const receipt = Receipt.view({ root: link, blocks: this.store })
receipts.set(`${receipt.ran.link()}`, receipt)
Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('build message with an invocation', async () => {
})

assert.deepEqual(message.root.data, {
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [echo.delegation.cid],
},
})
Expand Down Expand Up @@ -134,7 +134,7 @@ test('empty receipts are omitted', async () => {
assert.deepEqual(
message.root.data,
{
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [hi.delegation.cid],
},
},
Expand All @@ -153,7 +153,7 @@ test('message with receipts', async () => {
assert.deepEqual(
message.root.data,
{
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
report: {
[`${hi.delegation.cid}`]: hi.receipt.root.cid,
},
Expand All @@ -172,7 +172,7 @@ test('handles duplicate receipts', async () => {
assert.deepEqual(
message.root.data,
{
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
report: {
[`${hi.delegation.cid}`]: hi.receipt.root.cid,
},
Expand All @@ -195,7 +195,7 @@ test('empty invocations are omitted', async () => {
assert.deepEqual(
message.root.data,
{
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
report: {
[`${hi.delegation.cid}`]: hi.receipt.root.cid,
},
Expand Down Expand Up @@ -223,7 +223,7 @@ test('message with invocations & receipts', async () => {
assert.deepEqual(
message.root.data,
{
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [hi.delegation.cid],
report: {
[`${hi.delegation.cid}`]: hi.receipt.root.cid,
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ export type InferReceipts<
* Describes messages send across ucanto agents.
*/
export type AgentMessageModel<T> = Variant<{
'ucanto/message@0.6.0': AgentMessageData<T>
'ucanto/message@7.0.0': AgentMessageData<T>
}>

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/transport/test/car.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('encode / decode', async () => {
assertDecode(incoming, {
root: message.root,
data: {
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [delegation.cid],
},
},
Expand All @@ -35,7 +35,7 @@ test('accepts Content-Type as well', async () => {
{
root: message.root,
data: {
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [delegation.cid],
},
},
Expand Down Expand Up @@ -109,7 +109,7 @@ test('CAR.request encode / decode', async () => {
assertDecode(incoming, {
root: message.root,
data: {
'ucanto/message@0.6.0': {
'ucanto/message@7.0.0': {
execute: [delegation.cid],
},
},
Expand Down

0 comments on commit b79034b

Please sign in to comment.