Skip to content

Commit

Permalink
Add new version 5 of streaming payments
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony authored and chmanie committed Jun 20, 2024
1 parent f3f8292 commit 8761700
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import type { AugmentedIColony } from '../../Core/augments/commonAugments.js';
import type { StreamingPayments } from '../../../contracts/StreamingPayments/4/StreamingPayments.js';
import type { StreamingPayments } from '../../../contracts/StreamingPayments/5/StreamingPayments.js';

import { StreamingPayments__factory as StreamingPaymentsFactory } from '../../../contracts/StreamingPayments/4/factories/StreamingPayments__factory.js';
import { StreamingPayments__factory as StreamingPaymentsFactory } from '../../../contracts/StreamingPayments/5/factories/StreamingPayments__factory.js';
import { ClientType } from '../../../constants.js';
import {
addAugments,
AugmentedStreamingPayments,
ValidColony,
} from './augments/commonAugments.js';

export interface StreamingPaymentsClientV4
export interface StreamingPaymentsClientV5
extends AugmentedStreamingPayments<StreamingPayments> {
clientVersion: 4;
clientVersion: 5;
}

export default function getStreamingPaymentsClient(
colonyClient: AugmentedIColony<ValidColony>,
address: string,
): StreamingPaymentsClientV4 {
): StreamingPaymentsClientV5 {
const streamingPaymentsClient = StreamingPaymentsFactory.connect(
address,
colonyClient.signer || colonyClient.provider,
) as StreamingPaymentsClientV4;
) as StreamingPaymentsClientV5;

streamingPaymentsClient.clientType = ClientType.StreamingPaymentsClient;
streamingPaymentsClient.clientVersion = 4;
streamingPaymentsClient.clientVersion = 5;
addAugments(streamingPaymentsClient, colonyClient);

return streamingPaymentsClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { StreamingPayments as StreamingPayments1 } from '../../../contracts
import type { StreamingPayments as StreamingPayments2 } from '../../../contracts/StreamingPayments/2/index.js';
import type { StreamingPayments as StreamingPayments3 } from '../../../contracts/StreamingPayments/3/index.js';
import type { StreamingPayments as StreamingPayments4 } from '../../../contracts/StreamingPayments/4/index.js';
import type { StreamingPayments as StreamingPayments5 } from '../../../contracts/StreamingPayments/5/index.js';

// Always adjust to the latest factory
export { StreamingPayments__factory as StreamingPaymentsFactory } from '../../../contracts/StreamingPayments/4/factories/StreamingPayments__factory.js';
Expand All @@ -11,6 +12,7 @@ export type StreamingPaymentsV1 = StreamingPayments1;
export type StreamingPaymentsV2 = StreamingPayments2;
export type StreamingPaymentsV3 = StreamingPayments3;
export type StreamingPaymentsV4 = StreamingPayments4;
export type StreamingPaymentsV5 = StreamingPayments5;

// No one is using StreamingPaymentsV1 through V3, so we can safely ignore them for now
export type AnyStreamingPayments = StreamingPayments4;
// No one is using StreamingPaymentsV1 through V4, so we can safely ignore them for now
export type AnyStreamingPayments = StreamingPaymentsV5;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { assertExhaustiveSwitch } from '@colony/core/utils';
import { AugmentedIColony } from '../../Core/augments/commonAugments.js';
import { ValidColony } from './augments/commonAugments.js';

import getStreamingPaymentsClientV4, {
StreamingPaymentsClientV4,
} from './StreamingPaymentsClientV4.js';
import getStreamingPaymentsClientV5, {
StreamingPaymentsClientV5,
} from './StreamingPaymentsClientV5.js';

export { StreamingPaymentsClientV4 } from './StreamingPaymentsClientV4.js';
export { StreamingPaymentsClientV5 } from './StreamingPaymentsClientV5.js';

export type AnyStreamingPaymentsClient = StreamingPaymentsClientV4;
export type AnyStreamingPaymentsClient = StreamingPaymentsClientV5;

/** @internal */
export const getStreamingPaymentsClient = (
Expand All @@ -27,7 +27,9 @@ export const getStreamingPaymentsClient = (
case 3:
throw new Error('StreamingPayments version 3 is not supported');
case 4:
return getStreamingPaymentsClientV4(
throw new Error('StreamingPayments version 4 is not supported');
case 5:
return getStreamingPaymentsClientV5(
colonyClient as AugmentedIColony<ValidColony>,
address,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/contractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"homepage": "https://docs.colony.io/develop",
"dependencies": {
"@colony/abis": "0.0.0-snapshot-next-78ab0ee9",
"@colony/abis": "0.0.0-snapshot-next-78ab0ee9-08d6",
"@typechain/ethers-v5": "^11.1.0",
"@typechain/ethers-v6": "^0.4.2",
"@types/mkdirp": "^1.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/versions/StreamingPayments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ColonyVersion } from './IColony.js';

import { createContractVersionArray } from './utils.js';

const STREAMING_PAYMENTS_VERSION_NEXT = 5;
const STREAMING_PAYMENTS_VERSION_NEXT = 6;

/** @internal */
export const STREAMING_PAYMENTS_VERSIONS = createContractVersionArray(
Expand All @@ -21,6 +21,7 @@ export const streamingPaymentsIncompatibilityMap: Record<
2: [1, 2, 3],
3: [1, 2, 3],
4: [1, 2, 3],
5: [1, 2, 3],
};

/** @internal */
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8761700

Please sign in to comment.