members.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. import { createTypeUnsafe } from "@polkadot/types/create";
  2. import { SubstrateEvent, SubstrateExtrinsic } from "@dzlzv/hydra-common";
  3. import { Codec } from "@polkadot/types/types";
  4. import { typeRegistry } from ".";
  5. import { EntryMethod, MemberId, PaidTermId } from "@joystream/types/augment";
  6. import { AccountId, BalanceOf } from "@polkadot/types/interfaces";
  7. import { Bytes, Option } from "@polkadot/types";
  8. export namespace Members {
  9. export class MemberRegisteredEvent {
  10. public readonly expectedParamTypes = [
  11. "MemberId",
  12. "AccountId",
  13. "EntryMethod<PaidTermId, AccountId>"
  14. ];
  15. constructor(public readonly ctx: SubstrateEvent) {}
  16. get data(): MemberRegistered_Params {
  17. return new MemberRegistered_Params(this.ctx);
  18. }
  19. validateParams(): boolean {
  20. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  21. return false;
  22. }
  23. let valid = true;
  24. this.expectedParamTypes.forEach((type, i) => {
  25. if (type !== this.ctx.params[i].type) {
  26. valid = false;
  27. }
  28. });
  29. return valid;
  30. }
  31. }
  32. class MemberRegistered_Params {
  33. constructor(public readonly ctx: SubstrateEvent) {}
  34. get memberId(): MemberId {
  35. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  36. this.ctx.params[0].value
  37. ]);
  38. }
  39. get accountId(): AccountId {
  40. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  41. this.ctx.params[1].value
  42. ]);
  43. }
  44. get entryMethod(): EntryMethod {
  45. return createTypeUnsafe<EntryMethod & Codec>(
  46. typeRegistry,
  47. "EntryMethod",
  48. [this.ctx.params[2].value]
  49. );
  50. }
  51. }
  52. export class MemberUpdatedAboutTextEvent {
  53. public readonly expectedParamTypes = ["MemberId"];
  54. constructor(public readonly ctx: SubstrateEvent) {}
  55. get data(): MemberUpdatedAboutText_Params {
  56. return new MemberUpdatedAboutText_Params(this.ctx);
  57. }
  58. validateParams(): boolean {
  59. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  60. return false;
  61. }
  62. let valid = true;
  63. this.expectedParamTypes.forEach((type, i) => {
  64. if (type !== this.ctx.params[i].type) {
  65. valid = false;
  66. }
  67. });
  68. return valid;
  69. }
  70. }
  71. class MemberUpdatedAboutText_Params {
  72. constructor(public readonly ctx: SubstrateEvent) {}
  73. get memberId(): MemberId {
  74. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  75. this.ctx.params[0].value
  76. ]);
  77. }
  78. }
  79. export class MemberUpdatedAvatarEvent {
  80. public readonly expectedParamTypes = ["MemberId"];
  81. constructor(public readonly ctx: SubstrateEvent) {}
  82. get data(): MemberUpdatedAvatar_Params {
  83. return new MemberUpdatedAvatar_Params(this.ctx);
  84. }
  85. validateParams(): boolean {
  86. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  87. return false;
  88. }
  89. let valid = true;
  90. this.expectedParamTypes.forEach((type, i) => {
  91. if (type !== this.ctx.params[i].type) {
  92. valid = false;
  93. }
  94. });
  95. return valid;
  96. }
  97. }
  98. class MemberUpdatedAvatar_Params {
  99. constructor(public readonly ctx: SubstrateEvent) {}
  100. get memberId(): MemberId {
  101. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  102. this.ctx.params[0].value
  103. ]);
  104. }
  105. }
  106. export class MemberUpdatedHandleEvent {
  107. public readonly expectedParamTypes = ["MemberId"];
  108. constructor(public readonly ctx: SubstrateEvent) {}
  109. get data(): MemberUpdatedHandle_Params {
  110. return new MemberUpdatedHandle_Params(this.ctx);
  111. }
  112. validateParams(): boolean {
  113. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  114. return false;
  115. }
  116. let valid = true;
  117. this.expectedParamTypes.forEach((type, i) => {
  118. if (type !== this.ctx.params[i].type) {
  119. valid = false;
  120. }
  121. });
  122. return valid;
  123. }
  124. }
  125. class MemberUpdatedHandle_Params {
  126. constructor(public readonly ctx: SubstrateEvent) {}
  127. get memberId(): MemberId {
  128. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  129. this.ctx.params[0].value
  130. ]);
  131. }
  132. }
  133. export class MemberSetRootAccountEvent {
  134. public readonly expectedParamTypes = ["MemberId", "AccountId"];
  135. constructor(public readonly ctx: SubstrateEvent) {}
  136. get data(): MemberSetRootAccount_Params {
  137. return new MemberSetRootAccount_Params(this.ctx);
  138. }
  139. validateParams(): boolean {
  140. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  141. return false;
  142. }
  143. let valid = true;
  144. this.expectedParamTypes.forEach((type, i) => {
  145. if (type !== this.ctx.params[i].type) {
  146. valid = false;
  147. }
  148. });
  149. return valid;
  150. }
  151. }
  152. class MemberSetRootAccount_Params {
  153. constructor(public readonly ctx: SubstrateEvent) {}
  154. get memberId(): MemberId {
  155. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  156. this.ctx.params[0].value
  157. ]);
  158. }
  159. get accountId(): AccountId {
  160. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  161. this.ctx.params[1].value
  162. ]);
  163. }
  164. }
  165. export class MemberSetControllerAccountEvent {
  166. public readonly expectedParamTypes = ["MemberId", "AccountId"];
  167. constructor(public readonly ctx: SubstrateEvent) {}
  168. get data(): MemberSetControllerAccount_Params {
  169. return new MemberSetControllerAccount_Params(this.ctx);
  170. }
  171. validateParams(): boolean {
  172. if (this.expectedParamTypes.length !== this.ctx.params.length) {
  173. return false;
  174. }
  175. let valid = true;
  176. this.expectedParamTypes.forEach((type, i) => {
  177. if (type !== this.ctx.params[i].type) {
  178. valid = false;
  179. }
  180. });
  181. return valid;
  182. }
  183. }
  184. class MemberSetControllerAccount_Params {
  185. constructor(public readonly ctx: SubstrateEvent) {}
  186. get memberId(): MemberId {
  187. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  188. this.ctx.params[0].value
  189. ]);
  190. }
  191. get accountId(): AccountId {
  192. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  193. this.ctx.params[1].value
  194. ]);
  195. }
  196. }
  197. /**
  198. * Non-members can buy membership
  199. */
  200. export class BuyMembershipCall {
  201. public readonly extrinsic: SubstrateExtrinsic;
  202. public readonly expectedArgTypes = [
  203. "PaidTermId",
  204. "Option<Bytes>",
  205. "Option<Bytes>",
  206. "Option<Bytes>"
  207. ];
  208. constructor(public readonly ctx: SubstrateEvent) {
  209. if (ctx.extrinsic === undefined) {
  210. throw new Error(`No call data has been provided`);
  211. }
  212. this.extrinsic = ctx.extrinsic;
  213. }
  214. get args(): BuyMembership_Args {
  215. return new BuyMembership_Args(this.extrinsic);
  216. }
  217. validateArgs(): boolean {
  218. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  219. return false;
  220. }
  221. let valid = true;
  222. this.expectedArgTypes.forEach((type, i) => {
  223. if (type !== this.extrinsic.args[i].type) {
  224. valid = false;
  225. }
  226. });
  227. return valid;
  228. }
  229. }
  230. class BuyMembership_Args {
  231. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  232. get paidTermsId(): PaidTermId {
  233. return createTypeUnsafe<PaidTermId & Codec>(typeRegistry, "PaidTermId", [
  234. this.extrinsic.args[0].value
  235. ]);
  236. }
  237. get handle(): Option<Bytes> {
  238. return createTypeUnsafe<Option<Bytes> & Codec>(
  239. typeRegistry,
  240. "Option<Bytes>",
  241. [this.extrinsic.args[1].value]
  242. );
  243. }
  244. get avatarUri(): Option<Bytes> {
  245. return createTypeUnsafe<Option<Bytes> & Codec>(
  246. typeRegistry,
  247. "Option<Bytes>",
  248. [this.extrinsic.args[2].value]
  249. );
  250. }
  251. get about(): Option<Bytes> {
  252. return createTypeUnsafe<Option<Bytes> & Codec>(
  253. typeRegistry,
  254. "Option<Bytes>",
  255. [this.extrinsic.args[3].value]
  256. );
  257. }
  258. }
  259. /**
  260. * Screened members are awarded a initial locked balance that can only be slashed or used
  261. * for fees, and is not transferable. The screening authority must ensure that the provided
  262. * new_member_account was verified to avoid applying locks arbitrarily to accounts not controlled
  263. * by the member.
  264. */
  265. export class AddScreenedMemberCall {
  266. public readonly extrinsic: SubstrateExtrinsic;
  267. public readonly expectedArgTypes = [
  268. "AccountId",
  269. "Option<Bytes>",
  270. "Option<Bytes>",
  271. "Option<Bytes>",
  272. "Option<BalanceOf>"
  273. ];
  274. constructor(public readonly ctx: SubstrateEvent) {
  275. if (ctx.extrinsic === undefined) {
  276. throw new Error(`No call data has been provided`);
  277. }
  278. this.extrinsic = ctx.extrinsic;
  279. }
  280. get args(): AddScreenedMember_Args {
  281. return new AddScreenedMember_Args(this.extrinsic);
  282. }
  283. validateArgs(): boolean {
  284. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  285. return false;
  286. }
  287. let valid = true;
  288. this.expectedArgTypes.forEach((type, i) => {
  289. if (type !== this.extrinsic.args[i].type) {
  290. valid = false;
  291. }
  292. });
  293. return valid;
  294. }
  295. }
  296. class AddScreenedMember_Args {
  297. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  298. get newMemberAccount(): AccountId {
  299. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  300. this.extrinsic.args[0].value
  301. ]);
  302. }
  303. get handle(): Option<Bytes> {
  304. return createTypeUnsafe<Option<Bytes> & Codec>(
  305. typeRegistry,
  306. "Option<Bytes>",
  307. [this.extrinsic.args[1].value]
  308. );
  309. }
  310. get avatarUri(): Option<Bytes> {
  311. return createTypeUnsafe<Option<Bytes> & Codec>(
  312. typeRegistry,
  313. "Option<Bytes>",
  314. [this.extrinsic.args[2].value]
  315. );
  316. }
  317. get about(): Option<Bytes> {
  318. return createTypeUnsafe<Option<Bytes> & Codec>(
  319. typeRegistry,
  320. "Option<Bytes>",
  321. [this.extrinsic.args[3].value]
  322. );
  323. }
  324. get initialBalance(): Option<BalanceOf> {
  325. return createTypeUnsafe<Option<BalanceOf> & Codec>(
  326. typeRegistry,
  327. "Option<BalanceOf>",
  328. [this.extrinsic.args[4].value]
  329. );
  330. }
  331. }
  332. /**
  333. * Change member's about text
  334. */
  335. export class ChangeMemberAboutTextCall {
  336. public readonly extrinsic: SubstrateExtrinsic;
  337. public readonly expectedArgTypes = ["MemberId", "Bytes"];
  338. constructor(public readonly ctx: SubstrateEvent) {
  339. if (ctx.extrinsic === undefined) {
  340. throw new Error(`No call data has been provided`);
  341. }
  342. this.extrinsic = ctx.extrinsic;
  343. }
  344. get args(): ChangeMemberAboutText_Args {
  345. return new ChangeMemberAboutText_Args(this.extrinsic);
  346. }
  347. validateArgs(): boolean {
  348. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  349. return false;
  350. }
  351. let valid = true;
  352. this.expectedArgTypes.forEach((type, i) => {
  353. if (type !== this.extrinsic.args[i].type) {
  354. valid = false;
  355. }
  356. });
  357. return valid;
  358. }
  359. }
  360. class ChangeMemberAboutText_Args {
  361. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  362. get memberId(): MemberId {
  363. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  364. this.extrinsic.args[0].value
  365. ]);
  366. }
  367. get text(): Bytes {
  368. return createTypeUnsafe<Bytes & Codec>(typeRegistry, "Bytes", [
  369. this.extrinsic.args[1].value
  370. ]);
  371. }
  372. }
  373. /**
  374. * Change member's avatar
  375. */
  376. export class ChangeMemberAvatarCall {
  377. public readonly extrinsic: SubstrateExtrinsic;
  378. public readonly expectedArgTypes = ["MemberId", "Bytes"];
  379. constructor(public readonly ctx: SubstrateEvent) {
  380. if (ctx.extrinsic === undefined) {
  381. throw new Error(`No call data has been provided`);
  382. }
  383. this.extrinsic = ctx.extrinsic;
  384. }
  385. get args(): ChangeMemberAvatar_Args {
  386. return new ChangeMemberAvatar_Args(this.extrinsic);
  387. }
  388. validateArgs(): boolean {
  389. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  390. return false;
  391. }
  392. let valid = true;
  393. this.expectedArgTypes.forEach((type, i) => {
  394. if (type !== this.extrinsic.args[i].type) {
  395. valid = false;
  396. }
  397. });
  398. return valid;
  399. }
  400. }
  401. class ChangeMemberAvatar_Args {
  402. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  403. get memberId(): MemberId {
  404. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  405. this.extrinsic.args[0].value
  406. ]);
  407. }
  408. get uri(): Bytes {
  409. return createTypeUnsafe<Bytes & Codec>(typeRegistry, "Bytes", [
  410. this.extrinsic.args[1].value
  411. ]);
  412. }
  413. }
  414. /**
  415. * Change member's handle. Will ensure new handle is unique and old one will be available
  416. * for other members to use.
  417. */
  418. export class ChangeMemberHandleCall {
  419. public readonly extrinsic: SubstrateExtrinsic;
  420. public readonly expectedArgTypes = ["MemberId", "Bytes"];
  421. constructor(public readonly ctx: SubstrateEvent) {
  422. if (ctx.extrinsic === undefined) {
  423. throw new Error(`No call data has been provided`);
  424. }
  425. this.extrinsic = ctx.extrinsic;
  426. }
  427. get args(): ChangeMemberHandle_Args {
  428. return new ChangeMemberHandle_Args(this.extrinsic);
  429. }
  430. validateArgs(): boolean {
  431. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  432. return false;
  433. }
  434. let valid = true;
  435. this.expectedArgTypes.forEach((type, i) => {
  436. if (type !== this.extrinsic.args[i].type) {
  437. valid = false;
  438. }
  439. });
  440. return valid;
  441. }
  442. }
  443. class ChangeMemberHandle_Args {
  444. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  445. get memberId(): MemberId {
  446. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  447. this.extrinsic.args[0].value
  448. ]);
  449. }
  450. get handle(): Bytes {
  451. return createTypeUnsafe<Bytes & Codec>(typeRegistry, "Bytes", [
  452. this.extrinsic.args[1].value
  453. ]);
  454. }
  455. }
  456. export class SetRootAccountCall {
  457. public readonly extrinsic: SubstrateExtrinsic;
  458. public readonly expectedArgTypes = ["MemberId", "AccountId"];
  459. constructor(public readonly ctx: SubstrateEvent) {
  460. if (ctx.extrinsic === undefined) {
  461. throw new Error(`No call data has been provided`);
  462. }
  463. this.extrinsic = ctx.extrinsic;
  464. }
  465. get args(): SetRootAccount_Args {
  466. return new SetRootAccount_Args(this.extrinsic);
  467. }
  468. validateArgs(): boolean {
  469. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  470. return false;
  471. }
  472. let valid = true;
  473. this.expectedArgTypes.forEach((type, i) => {
  474. if (type !== this.extrinsic.args[i].type) {
  475. valid = false;
  476. }
  477. });
  478. return valid;
  479. }
  480. }
  481. class SetRootAccount_Args {
  482. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  483. get memberId(): MemberId {
  484. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  485. this.extrinsic.args[0].value
  486. ]);
  487. }
  488. get newRootAccount(): AccountId {
  489. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  490. this.extrinsic.args[1].value
  491. ]);
  492. }
  493. }
  494. export class SetControllerAccountCall {
  495. public readonly extrinsic: SubstrateExtrinsic;
  496. public readonly expectedArgTypes = ["MemberId", "AccountId"];
  497. constructor(public readonly ctx: SubstrateEvent) {
  498. if (ctx.extrinsic === undefined) {
  499. throw new Error(`No call data has been provided`);
  500. }
  501. this.extrinsic = ctx.extrinsic;
  502. }
  503. get args(): SetControllerAccount_Args {
  504. return new SetControllerAccount_Args(this.extrinsic);
  505. }
  506. validateArgs(): boolean {
  507. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  508. return false;
  509. }
  510. let valid = true;
  511. this.expectedArgTypes.forEach((type, i) => {
  512. if (type !== this.extrinsic.args[i].type) {
  513. valid = false;
  514. }
  515. });
  516. return valid;
  517. }
  518. }
  519. class SetControllerAccount_Args {
  520. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  521. get memberId(): MemberId {
  522. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  523. this.extrinsic.args[0].value
  524. ]);
  525. }
  526. get newControllerAccount(): AccountId {
  527. return createTypeUnsafe<AccountId & Codec>(typeRegistry, "AccountId", [
  528. this.extrinsic.args[1].value
  529. ]);
  530. }
  531. }
  532. /**
  533. * Update member's all or some of handle, avatar and about text.
  534. */
  535. export class UpdateMembershipCall {
  536. public readonly extrinsic: SubstrateExtrinsic;
  537. public readonly expectedArgTypes = [
  538. "MemberId",
  539. "Option<Bytes>",
  540. "Option<Bytes>",
  541. "Option<Bytes>",
  542. ];
  543. constructor(public readonly ctx: SubstrateEvent) {
  544. if (ctx.extrinsic === undefined) {
  545. throw new Error(`No call data has been provided`);
  546. }
  547. this.extrinsic = ctx.extrinsic;
  548. }
  549. get args(): UpdateMembership_Args {
  550. return new UpdateMembership_Args(this.extrinsic);
  551. }
  552. validateArgs(): boolean {
  553. if (this.expectedArgTypes.length !== this.extrinsic.args.length) {
  554. return false;
  555. }
  556. let valid = true;
  557. this.expectedArgTypes.forEach((type, i) => {
  558. if (type !== this.extrinsic.args[i].type) {
  559. valid = false;
  560. }
  561. });
  562. return valid;
  563. }
  564. }
  565. class UpdateMembership_Args {
  566. constructor(public readonly extrinsic: SubstrateExtrinsic) {}
  567. get memberId(): MemberId {
  568. return createTypeUnsafe<MemberId & Codec>(typeRegistry, "MemberId", [
  569. this.extrinsic.args[0].value,
  570. ]);
  571. }
  572. get handle(): Option<Bytes> {
  573. return createTypeUnsafe<Option<Bytes> & Codec>(
  574. typeRegistry,
  575. "Option<Bytes>",
  576. [this.extrinsic.args[1].value]
  577. );
  578. }
  579. get avatarUri(): Option<Bytes> {
  580. return createTypeUnsafe<Option<Bytes> & Codec>(
  581. typeRegistry,
  582. "Option<Bytes>",
  583. [this.extrinsic.args[2].value]
  584. );
  585. }
  586. get about(): Option<Bytes> {
  587. return createTypeUnsafe<Option<Bytes> & Codec>(
  588. typeRegistry,
  589. "Option<Bytes>",
  590. [this.extrinsic.args[3].value]
  591. );
  592. }
  593. }
  594. }