Skip to content

Commit

Permalink
fix: Memo type should be (string | ArrayBuffer)[] (#96)
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Larsen <hans@larsen.online>
  • Loading branch information
stanleyjones and hansl authored Mar 1, 2023
1 parent 7495f24 commit 8b80bb6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/network/modules/account/__tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Account", () => {
to: "m123",
from: "m321",
symbol: "m456",
memo: "this is a memo",
memo: ["this is a memo"],
executeAutomatically: false,
threshold: 3,
expireInSecs: 3600,
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("Account", () => {
)
expect(res).toEqual({
info: {
memo: "this is a memo",
memo: ["this is a memo"],
transaction: {
type: EventType.send,
from: accountSource,
Expand Down Expand Up @@ -358,7 +358,7 @@ function makeMultisigInfoResponse({
.set(5, executeAutomatically)
.set(6, tag(1, expireDate))
.set(8, txnState)
.set(9, "this is a memo")
.set(9, ["this is a memo"])
}

function makeAccountFeatures(): AccountFeature[] {
Expand Down
11 changes: 5 additions & 6 deletions src/network/modules/events/__tests__/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
AccountRole,
EventType,
EventTypeIndices,
Memo,
} from "../../types"
import {
accountSource,
Expand Down Expand Up @@ -89,25 +90,23 @@ function makeMultisigSubmitTxnResponse({
txnTypeIndices = eventTypeNameToIndices.accountMultisigSubmit,
submitter,
accountSource,
memo = "",
memo = [""],
submittedTxn,
token = new Uint8Array(),
threshold,
executeAutomatically = false,
cborData,
expireDate = new Date(new Date().getTime() + ONE_MINUTE).getTime(),
time,
}: {
id: number
txnTypeIndices?: EventTypeIndices
submitter: string
accountSource: string
memo?: string
memo?: Memo
submittedTxn: Map<number, unknown>
token?: ArrayBuffer
threshold: number
executeAutomatically: boolean
cborData?: Map<number, unknown>
expireDate?: number
time: number
}) {
Expand Down Expand Up @@ -205,7 +204,7 @@ export const mockEventsListMultisigSubmitEventResponse =
submitter: identityStr2,
accountSource,
threshold: 2,
memo: "this is a memo",
memo: ["this is a memo"],
executeAutomatically: false,
expireDate,
submittedTxn: new Map().set(0, eventTypeNameToIndices.send).set(
Expand All @@ -228,7 +227,7 @@ export const expectedMockEventsListMultisigSubmitEventResponse = {
type: EventType.accountMultisigSubmit,
submitter: identityStr2,
account: accountSource,
memo: "this is a memo",
memo: ["this is a memo"],
token: new Uint8Array(),
expireDate,
threshold: 2,
Expand Down
4 changes: 2 additions & 2 deletions src/network/modules/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EventType,
EventTypeIndices,
ListOrderType,
Memo,
NetworkModule,
RangeBounds,
} from "../types"
Expand Down Expand Up @@ -92,13 +93,12 @@ export interface MultisigSetDefaultsEvent extends MultisigEvent {
export interface MultisigSubmitEvent extends MultisigEvent {
account: string
executeAutomatically: boolean
memo: string
memo: Memo
submitter: string
threshold: number
expireDate: number
token: ArrayBuffer
transaction: Omit<Event, "id" | "time"> | undefined
data?: CborMap
}

export type Event =
Expand Down
2 changes: 1 addition & 1 deletion src/network/modules/tokens/__tests__/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Tokens", () => {
name: "OurToken",
symbol: "OTK",
precision: 9,
memo: "Now decentralized!",
memo: ["Now decentralized!"],
})

expect(mockCall).toHaveBeenCalled()
Expand Down
4 changes: 2 additions & 2 deletions src/network/modules/tokens/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from "../../../identity"
import { NetworkModule } from "../types"
import { Memo, NetworkModule } from "../types"

type LedgerAmount = BigInt
type AttrIndex = number | [number, AttrIndex]
Expand Down Expand Up @@ -48,7 +48,7 @@ export interface TokensUpdateParam {
symbol?: string
precision?: number
owner?: string | null
memo?: string
memo?: Memo
}

export interface TokensAddExtendedParam {
Expand Down
2 changes: 1 addition & 1 deletion src/network/modules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export enum MultisigTransactionState {
expired,
}

export type Memo = string
export type Memo = (string | ArrayBuffer)[]

export enum BoundType {
unbounded = "unbounded",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
AccountMultisigArgument,
MultisigSetDefaultsEvent,
AddFeaturesEvent,
Memo,
} from "../../network"

export function makeLedgerSendParam({
Expand Down Expand Up @@ -293,6 +294,6 @@ async function makeMultisigSubmitEventData(
threshold: eventData.get(6) as number,
expireDate: eventData.get(7)?.value,
executeAutomatically: eventData.get(8) as boolean,
memo: eventData.get(10) as string,
memo: eventData.get(10) as Memo,
}
}

0 comments on commit 8b80bb6

Please sign in to comment.